JS—手机端上拉加载数据功能
<div class="jiaz centers wid100">
加载中...
</div>
var page = 1,timers=null,limit = 5,;
$(function() {
page = 1;
$(window).scroll(function() {
let scrollTop = Math.ceil($(this).scrollTop())
let curHeight = $(this).height()
let totalHeight = $(document).height()
if (scrollTop + curHeight >= totalHeight) {
clearTimeout(timers);
timers = setTimeout(() => {
page++
$('.jiaz').css('display','block')
console.log("第" + page + "页");
goodsAll(keywords, is_show, type_id)
}, 500)
}
})
});
function goodsAll(keywords, is_show, type_id) {
....
success: function(res) {
dataInfo = res.data;
if (page > 1) {
data = data.concat(res.data);
} else {
$('.infoD').empty();
}
}
.....
}
.jiaz {
font-size: 14px;
color: #555555;
display: none;
height: 40px;
line-height: 40px;
}