简体   繁体   English

通过$ .ajax()方法调用时,为什么未显示jQuery colorbox弹出窗口?

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

I'm calling a hidden colorbox popup in the $.ajax() method's success: function() but I'm not able to show that. 我在$ .ajax()方法的成功调用了一个隐藏的colorbox弹出窗口:function(),但我无法显示出来。 I did the same thing previously but at that time it worked fine, now it's not displaying the specified hidden pop-up. 之前我做过同样的事情,但当时效果很好,现在没有显示指定的隐藏弹出窗口。 The only difference from this implementation to previous implementation I was using data attrribute of $.ajax() method in the previous implementation. 从此实现到以前的实现的唯一区别是,我在先前的实现中使用了$ .ajax()方法的数据属性。 Does that thing is responsible for my current issue? 那件事负责我当前的问题吗? Please help me out in resolving this issue. 请帮助我解决此问题。 For your reference I'm putting the necessary code snippets as follows: 供您参考,我将必要的代码段如下:

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

One more thing I wold like to say is I'm getting the proper response from PHP code in json format, if I show alert instead of colorbox it shows the desired response properly. 我想说的另一件事是,我从JSON格式的PHP代码中获得了正确的响应,如果我显示警报而不是颜色框,它将正确显示所需的响应。 There are no syntactical errors found in firebug console and I'm using jQuery 1.9 在Firebug控制台中未发现语法错误,我使用的是jQuery 1.9

try adding open: true , like: 尝试添加open: true ,例如:

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

You can try something like this. 您可以尝试这样。 I am not sure about this 我对此不确定

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

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

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