分类:
架构
js实现当快滚动到底部时刷新数据
$(window).scroll(function () {
var scrollTop = $(this).scrollTop();
var windowHeight = document.body.clientHeight;
var scrollHeight = $(document).height();
console.log(scrollTop);
console.log(windowHeight);
console.log(scrollHeight);
console.log("----------------------------");
if (scrollTop + windowHeight + 186 >= scrollHeight) {
if (isdo) {
isdo = false;
getResourceOthers();
}
}
});
var page = 1;
//防止滚动事件连续执行,在数据没有返回解析成功之前就不让他触发再次去请求后台了
var isdo = true;
var getResourceOthers = function ()
{
console.log('到底了请求一次数据');
//发送ajax,获取数据
$.post('/x/j', function () {
page++;
isdo = true;
});
}要注意获取页面可视度高度的坑:
https://www.tnblog.net/aojiancc6/article/details/4043
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)
评价
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256
50010702506256
欢迎加群交流技术