繁体   English   中英

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

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

我正在创建页面加载的图像元素,并为此在AJAX POST jquery方法中编写了代码。 因此,图像的小图标即将出现在页面上。 当我单击document.ready(onclick)上的图像时,它必须在模式弹出窗口中打开很大,但是没有打开。但是,空白弹出窗口正在打开。

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);
    }
   }
 }
});

现在在页面代码

   // 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 + "' />")
     })
  });

问题是什么 ? 有人可以帮忙吗? (目标是打开模态弹出窗口上的小图像。)

尝试纠正这个

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

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

因为result是对象,所以您需要使用d捕获数据

暂无
暂无

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

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