0

I'm trying to implement infinite scroll. Full code

jQuery(document).ready(function($) {
    $(window).scroll(function() {
        var that = $('#loadMore');
        var page = $('#loadMore').data('page');
        var newPage = page + 1;
        var ajaxurl = $('#loadMore').data('url');
      
        if ($(window).scrollTop() + $(window).height() == $(document).height()) {
          
            $.ajax({
                url: ajaxurl,
                type: 'post',
                data: {
                    page: page,
                    action: 'ajax_script_load_more'
                },
                error: function(response) {
                    console.log(response);
                },
                success: function(response) {
                    //check
                    if (response == 0) {
                        //check
                        if ($("#no-more").length == 0) {
                            $('#ajax-content').append('<div id="no-more" class="text-center"><h3>You reached the end of the line!</h3><p>No more posts to load.</p></div>');
                        }
                        $('#loadMore').hide();
                    } else {
                        $('#loadMore').data('page', newPage);
                        $('#ajax-content').append(response);
                    }
                }
            });
        }
    });
});

This works fine on my computer, but does not work on any browsers on mobile (Android/iOS).

Any help would be appreciated!

Niicow
  • 1
  • 1
  • I would suggest removing code from the title and using something more descriptive instead. How about "Infinite Scroll Implementation Not Working On Mobile Browsers"? This would make your question a lot more readable, even to those familiar with the topic. – Simeon G Dec 29 '20 at 02:50
  • 1
    https://stackoverflow.com/questions/24728140/jquery-mobile-1-4-infinite-scrolling-window-scroll-not-firing/24728709#24728709 Check demo for code. – Omar Dec 29 '20 at 06:56

0 Answers0