jquery滚动条加载数据
//滚动条
$(window).scroll(function () {
var scrollTop = $(this).scrollTop();
var scrollHeight = $(document).height();
var windowHeight = $(this).height();
var data = $("#n").text();
console.log(data);
if (scrollTop + windowHeight == scrollHeight) {
//此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
$.ajax({
url: basePath+'/daily/toDailyDebtNextPage.shtml',
type: 'GET',
dataType: "json",
//timeout: 15000,
cache:false,
data:data,
beforeSend: function (e){
},
success: function(data, status){
var html = '';
var list = data.debtList;
for (var i = list.length - 1; i >= 0; i--) {
html += '<div class="list_box"><div class="con"><table><tr><td>标的类型</td><td class="r m">'+list[i].debType+'</td></tr><tr><td>借款人身份证号</td><td class="r no'+data.maxId+'">'+list[i].debtorIdentityNo+'</td></tr><tr><td>借款用途</td><td class="r">'+list[i].debtPurpose+'</td></tr><tr><td>借款金额(元)</td><td class="f_yellow r">'+list[i].loanReceiptAmt+'</td></tr></table></div></div>';
};
$('#list').append(html);
geshi(data.maxId);
console.log(data);
var maxRecords = parseInt(data.maxRecords);
//var startId = 0;
var startId = parseInt(data.maxId)+1;
var userId = parseInt(data.userId);
var prodNo = data.prodNo;
var data ="userId="+userId+"&prodNo="+prodNo+"&startId="+startId+ "&maxRecords="+maxRecords;
if(list.length<maxRecords)
{$('#m').html("加载完毕..")};
$('#n').text(data);
},
error: function(XMLHttpRequest,event,ajaxOptions, thrownError){
}
});
}
});
原文地址:http://www.35ui.cn/post/20160311921.html