簡體   English   中英

通過$ .ajax()方法調用時,為什么未顯示jQuery colorbox彈出窗口?

[英]Why the jQuery colorbox popup is not getting displayed when called through $.ajax() method?

我在$ .ajax()方法的成功調用了一個隱藏的colorbox彈出窗口:function(),但我無法顯示出來。 之前我做過同樣的事情,但當時效果很好,現在沒有顯示指定的隱藏彈出窗口。 從此實現到以前的實現的唯一區別是,我在先前的實現中使用了$ .ajax()方法的數據屬性。 那件事負責我當前的問題嗎? 請幫助我解決此問題。 供您參考,我將必要的代碼段如下:

    <div class="hidden">
      <div id="emailinfoPopContent" class="c-popup">
        <h2 class="c-popup-header">Email Invoice</h2>
        <div class="c-content">         
          <h3>Invoice has been sent to your email id</h3>
        </div>
      </div>
    </div>

    <script language="javascript" type="text/javascript">
    $(document).ready(function(){   
    $(document).on('click', '#email_url', function (e) { 

    e.preventDefault();

    var post_url = $(this).attr('href');

    $.ajax({
      url: post_url,
      type : 'get',
      dataType: 'json',
      success: function(data) {
      var status       = data.status;
      var dialog_title = "Email Invoice";
      var message      = data.msg; 

      if(status == 'success') {
        $.colorbox({
          inline:true, 
          href: "#emailinfoPopContent",
          width:666
        });
        //alert(message);          
      } else {     
        $.colorbox({
          inline:true, 
          href: "#emailinfoPopContent",
          width:666
          });    
        //alert(message);           
        }  
      }
    });  
  });
});

</script>

我想說的另一件事是,我從JSON格式的PHP代碼中獲得了正確的響應,如果我顯示警報而不是顏色框,它將正確顯示所需的響應。 在Firebug控制台中未發現語法錯誤,我使用的是jQuery 1.9

嘗試添加open: true ,例如:

$.colorbox({
    inline:true, 
    href: "#emailinfoPopContent",
    width:666,
    open: true
});

您可以嘗試這樣。 我對此不確定

var show_html = $('emailinfoPopContent').html();
   $.colorbox({html:show_html});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM