Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Ajax infinite scroll only triggering once on page end

$
0
0

I can't work out why this is not working. When I scroll to the end it triggers the Ajax and gives me html which appends to the element, however this only works once, if I keep scrolling it doesn't work again so it's not endless scroll. Anyone know what I'm doing wrong here ? 

   <script>

    $(document).scroll(function(e){

        if($(document).scrollTop()+$(window).height()>$(document).height()-1000){

            $(document).off('scroll');

            //$('html, body').stop();

            $.ajax({

                type:"GET",

                url:"/home/getFreshAJAX_Post/",

                data: null

            }).done(function(viewHTML){

                //alert('The count of the html characters in the view is; ' + viewHTML.count)

                $("#appendContentHere ").append(viewHTML);

                $('#index_count').attr('value', viewHTML.index_count);

                if (viewHTML.count !=0) {

                    $(document).scroll(function(e){

                        //callback to the method to check if the user scrolled to the last element of your list/feed

                    })

                }

            });

        };

    });

    </script>


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>