0
我有一个jquery脚本正确加载无限滚动设置的新页面。我想要做的就是让它在距离底部300px的地方说出来,然后加载更多。我现在能够做到这一点,但不幸的是滚动注册多次,阿贾克斯加载页面的其余部分。我试过setTimeout无济于事。延迟无限滚动jQuery或JavaScript
(function(){
//inner functions will be aware of this
var currentPage = 1;
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 300) {
$.ajax({
type: "GET",
url: "posts/page/" + currentPage,
data: "",
success: function(results){
$(".container").append(results).masonry('reload');
}
})
setTimeout(currentPage++,3000);
}
});
})();
完美:)只是出于好奇心xhr代表什么? – bswinnerton
@bswinnerton:'XMLHttpRequest' – zerkms