jQuery实现滚动条下拉时无限加载

var lastId=0;//记录每一次加载时的最后一条记录id,跟您的排序方式有关。
var isloading = false;
$(window).bind("scroll", function () {
    if ($(document).scrollTop() + $(window).height() 
          > $(document).height() - 10 && !isloading) {
        isloading = true;
        getMore();
    }
});

function getMore() {
    var url = "ajaxdata.aspx"?lastId=" + lastId +"&type=" + 其他参数
    $.getJSON(url, function (data) {
        var html="";
        // ... ...
        $(html).insertAfter($(".elem").last());
        isloading = false;
   }
}
posted @ 2019-06-24 11:10  web前端参天大圣  阅读(1785)  评论(1)    收藏  举报