【问题标题】:ajax popup center in body load from another page来自另一个页面的正文加载中的 ajax 弹出中心
【发布时间】:2015-06-18 07:41:21
【问题描述】:

我想在身体中心加载弹出窗口怎么做..这是我的所有代码..请帮助我..谢谢...

头部样式

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://dinbror.dk/bpopup/assets/jquery.bpopup-0.11.0.min.js"></script>
<script src="http://dinbror.dk/bpopup/assets/scripting.min.js"></script>

jQuery

<script>
      jQuery(function ($) {

        $('.button').on('click', function () {
            var id = $(this).data('id');

            $.ajax({
                url: '/shopping/ajax.php',
                data: {
                    id: id
                },
                method: 'POST',
                success: function (html) {
                    $('body').append(html);
                    $(html).bPopup();
                },
                error: function (returnValue) {}
            });
        });


    });
</script>

按钮 html

<button type="button" class="button small pop1" data-id="1521" >Add to Cart</button>

【问题讨论】:

  • 为什么要将 html 附加到正文?

标签: javascript jquery html css ajax


【解决方案1】:

如果你的意思是在成功后输入 html 和 cheng css set

 success: function (html) {
     $('#popup').append(html);
     $('#popup').css('display','block');
     $(html).bPopup();
 },

http://fiddle.jshell.net/uzwL48k2/

【讨论】:

    【解决方案2】:

    id 为 #popup 的 div 缺少 css margin : 0px auto

    应用这个 css

    #popup {margin: 0px auto;}
    

    【讨论】:

      猜你喜欢
      • 2014-04-25
      • 1970-01-01
      • 2012-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多