我使用ajax从Web服务动态加载XML,返回的记录仅限于每个url'load'或'call'的25个项目。 ...为了解决这个问题,我有一个用户向下滚动页面的过程,当他们达到页面高度的90%(或者当他们到达页面底部时 - 不知道我会选择哪一个),一个名为startindexnum的变量由25如何检测何时页面滚动到底部并执行函数一次
增加,以致startindexnum开始了在25 ...那么函数的第一个“火”之后,startindexnum变为50,它成为75第三,等等,等等
我问题是它会多次触发并且有点不稳定 - 处理多次,当我滚动到底部,有时增加超过25(毫无疑问,我认为是多次运行的结果)。
任何人都知道我需要调整以获得此正确生成增量startindex变量追加到我检索XML的Ajax URL吗?谢谢。
var scrollcount = 1;
var startindexnum = 25;
var processing;
$(document).ready(function(){
$(document).scroll(function(e){
if (processing)
return false;
window.onscroll = function(ev) {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight){
//if ($(window).scrollTop() >= ($(document).height() - $(window).height())*0.9){
// you're at x% of the page
processing = true;
scrollcount = scrollcount + 1;
startindexnum = scrollcount * startindexnum;
console.log(scrollcount);
docall();
processing = false;
};
};
});
});
使用解除绑定尝试()?表格再次渲染后 - 再次绑定该方法? – user1428716 2013-02-20 14:35:22
btw ..你为什么要有window.onscroll和$ document.scroll? – user1428716 2013-02-20 14:37:28