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;
}
}
本文介绍了一种使用JavaScript实现的无限滚动加载技术。该技术通过监听页面滚动事件,在接近页面底部时自动加载更多数据。具体实现包括记录每次加载的最后一条记录ID、加载状态标记及AJAX调用获取新数据。
7547

被折叠的 条评论
为什么被折叠?



