页面向下滚动ajax获取数据的实现方法(兼容手机)
if (scrollTop + windowHeight >= scrollHeight) {
loadPromotions();
}
});
var page = 1;
var morAvaliable = true;//标识还有数据可以加载
function loadPromotions() {
if (morAvaliable) {
var href = location.href.split('?')[0];
var pageSize = 5;
page++;
$.post(href,{
pageNo: page,pageSize: pageSize
},function (data) {
if (data.length) {
var html = '';
$.each(data,function (i,list) {
html += '<div class="task-time">' + list.CreateTime + '
html += '<a class="task-Box" href="' + list.Url + '">';
html += '
' + list.Title + '
';});
$('#promotionList').append(html);
}
else {
morAvaliable = false;
$('#loading').html('没有更多分享信息了');
}
}
);
}
}