
根据滚动条高度来判断是否加载下一页
i = 1; //设置当前页数
function getJson(page) {
var msg_list = $('#lists');
if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) {
$(".nodata").show().html("<img src='http://www.sucaihuo.com/Public/images/loading.gif'/>");
$.getJSON("ajax.php", {page: i}, function(json) {
if (json) {
var str = "";
$.each(json, function(index, array) {
var str = "<div class='per'>";
var str = str + "<div class='title'>" + array['id'] + "、" + array['title'] + "</div></div>";
$("#lists").append(str);
});
$(".nodata").hide()
} else {
showEmpty();
}
});
i++;
}
}
远程div局部ajax加载数据http://www.sucaihuo.com/js/783.html