簡體   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