I am having trouble with jQuery functionality on my website.(我在我的网站上无法使用jQuery功能。)
What it does, is that it uses the window.scroll()
function to recognize when the windows changes its scroll position and at the change calls a few functions to load data from the server.(它的作用是使用window.scroll()
函数来识别窗口何时更改其滚动位置,并在更改时调用一些函数来从服务器加载数据。)
The problem is the .scroll()
function is called as soon as there is even a little change in the scroll position and loads data at the bottom;(问题在于, .scroll()
滚动位置有一点变化并在底部加载数据,就会立即调用.scroll()
函数。) however, what I wish to achieve is to load new data when the scroll/page position reaches at the bottom, like it happens for Facebook feed.(但是,我希望实现的是在滚动/页面位置到达底部时加载新数据,就像Facebook feed那样。)
But I am not sure how to detect scroll position using jQuery?(但是我不确定如何使用jQuery检测滚动位置吗?)
function getData() {
$.getJSON('Get/GetData?no=1', function (responseText) {
//Load some data from the server
})
};
$(window).scroll(function () {
getData();
});
ask by Maven translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…