简体   繁体   English

无法将小图像传递到模式弹出窗口并显示

[英]Unable to pass small image to modal popup and display it

I am creating image elements of load of a page and written the code in AJAX POST jquery method for it. 我正在创建页面加载的图像元素,并为此在AJAX POST jquery方法中编写了代码。 So small icons of image are coming on page. 因此,图像的小图标即将出现在页面上。 When I click on the image on document.ready(onclick) it must open big in modal pop up but it is not opening.However blank pop up is opening. 当我单击document.ready(onclick)上的图像时,它必须在模式弹出窗口中打开很大,但是没有打开。但是,空白弹出窗口正在打开。

loadup.js code loadup.js代码

$.ajax({
    type: "POST",
    url: "php/loadimages_f.php",
     dataType : 'json',
    success: function (result) {
        //alert(result);
         if(result==0){
       $("#friends_list_insert").after(" No Friends Yet...");
   }
    else{   
    for(var i = 0; i < result.length; i++)
        {
             var PP_PATH;
            PP_PATH="php/"+result[i].Photo_URL;
          var li_post="<li class='imggalli' style='list-style:none;'><a 
    href='#' data-toggle='modal' data-target='#myModal2' class='thumbnailimg' title='Image"+i+"'><img src='"+PP_PATH+"' style='margin:2px;width:65px;height:65px;' class='img-responsive' id='img"+i+"'></a></li>";

          $("#img_gallery_append").append(li_post);
    }
   }
 }
});

now on page code 现在在页面代码

   // Function for image pop up
     $(document).ready(function() {
       $('img').on('click', function() {
         $("#showImg").empty();
          // alert(this.id);
         var image = $(this).attr("src");
         $("#showImg").append("<img class='img-responsive' src='" + image + "' />")
     })
  });

What is the problem ? 问题是什么 ? Could anyone help please ? 有人可以帮忙吗? ( Objective is opening the small image on the modal pop up..) (目标是打开模态弹出窗口上的小图像。)

try to correct this 尝试纠正这个

PP_PATH="php/"+result[i].Photo_URL;

with

PP_PATH="php/"+result.d[i].Photo_URL;

because result is object, and you need to catch the data with d 因为result是对象,所以您需要使用d捕获数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM