var page = 1; //当前页的页码
function showAjax(page){
if (catid!=undefined) {
$.ajax({
url:"",
type:"",
dataType:"",
success:function(data){
$('#listContent').append(data);
}
})
}
}
$(window).scroll(function () {
//真实内容的高度
var pageHeight = Math.max(document.body.scrollHeight,document.body.offsetHeight);
//视窗的高度
var viewportHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0;
//隐藏的高度
var scrollHeight = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
if(pageHeight - viewportHeight - scrollHeight < 10){ //如果满足触发条件,执行
page++;
showAjax(page);
}
});
js移动端无限加载 简单实用
最新推荐文章于 2023-03-17 18:39:18 发布