简体   繁体   中英

ajax popup center in body load from another page

i want to load popup in body center how to do it.. here is my all codes.. plzz help me for it.. thanks...

head style

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

Button html

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

if you mean somthing like this after success you input in html and cheng css set

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

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

css margin : 0px auto is missing to your div with id #popup

Apply this css

#popup {margin: 0px auto;}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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