[英]Loading same content again and again on Ajax auto loading while scrolling
我使用来自互联网的名为“ jqueryscrollpagination”的脚本从网上自动加载内容,同时用户滚动到底部,因为我的页面太长了。 实时链接-http ://www.arif-khan.net/project/chuck/jobOpening.html
我的问题是它在底部滚动一次又一次显示相同的内容。 我该如何解决?
JavaScript代码-
<script type="text/javascript">
$(function(){
$('#content').scrollPagination({
'contentPage': 'more_content.html', // the url you are fetching the results
'contentData': {}, // these are the variables you can pass to the request, for example: children().size() to know which page you are
'scrollTarget': $(window), // who gonna scroll? in this example, the full window
'heightOffset': 10, // it gonna request when scroll is 10 pixels before the page ends
'beforeLoad': function(){ // before load function, you can display a preloader div
$('#loading').fadeIn();
},
'afterLoad': function(elementsLoaded){ // after loading content, you can use this function to animate your new elements
$('#loading').fadeOut();
var i = 0;
$(elementsLoaded).fadeInWithDelay();
if ($('#content').children().size() > 100){ // if more than 100 results already loaded, then stop pagination (only for testing)
$('#nomoreresults').fadeIn();
$('#content').stopScrollPagination();
}
}
});
// code for fade in element by element
$.fn.fadeInWithDelay = function(){
var delay = 0;
return this.each(function(){
$(this).delay(delay).animate({opacity:1}, 200);
delay += 100;
});
};
});
</script>
&它也使用另一个脚本文件。 检查这里-http ://www.arif-khan.net/project/chuck/scripts/scrollpagination.js
只是一个猜测,但是如果url每次都没有改变,则最终将得到内容的缓存副本,一遍又一遍地导致相同的数据,除非服务器发送的是非缓存头。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.