您的位置:首页 > Web前端 > JQuery

jquery 滚动到底部加载

2015-10-28 17:21 696 查看
var body_ = $(window);
var indexPage = 2;
var pageCount = <?php echo $pageCount;?>;
var _ajaxRequest = true;
body_.scroll(function () {
var viewH = $(this).height(),//可见高度
contentH = $(document).height(),//内容高度
scrollTop = $(this).scrollTop();//滚动高度
var _bottomDist = contentH - viewH - scrollTop;
if(_ajaxRequest && _bottomDist <= 50 && indexPage <= pageCount){
_ajaxRequest = false;
$.ajax({
type: 'POST',
url: 'url?page=' + indexPage,
dataType: 'text',
success:function(data){
indexPage = indexPage + 1;
_ajaxRequest = true;
$('.div').append(data);
}
});
}
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: