On Scroll down how to make ajax call and get the respone data

后端 未结 2 718
无人及你
无人及你 2020-12-19 23:55

Please can you people guide me how to make ajax call when scroll down

相关标签:
2条回答
  • 2020-12-20 00:02
    var no=1;
    $(window).scroll(function () {
        if(no==1)
        {
            if ($(window).height() + $(window).scrollTop() == $(document).height()) {
                no=2;
                $.ajax({
                    type: "POST",
                    url: "request.php",
                    data: datas,
                    cache: false,
                    success: function(html){
    
                    }
                });
            }
        }
    });
    

    This does an ajax call when a user reaches at end of page.

    You can specify a height at which it occurs.

    0 讨论(0)
  • 2020-12-20 00:13

    Here is a separate stack overflow question about firing events on scrolling:

    jQuery window scroll event does not fire up

    And here is jquery's manual that shows how to use ajax:

    http://api.jquery.com/jQuery.ajax/

    Combine and enjoy!

    0 讨论(0)
提交回复
热议问题