简体   繁体   中英

Loading same content again and again on Ajax auto loading while scrolling

I use a script from internet named "jqueryscrollpagination" from online for auto loading content while user scrolling to the bottom because my page is too long. Live link- http://www.arif-khan.net/project/chuck/jobOpening.html

My problem is it shows same content again & again after scrolling at the bottom. How can i fix it?

Javascript code-

    <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>

& it also uses another script file. Check here- http://www.arif-khan.net/project/chuck/scripts/scrollpagination.js

只是一个猜测,但是如果url每次都没有改变,则最终将得到内容的缓存副本,一遍又一遍地导致相同的数据,除非服务器发送的是非缓存头。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM