0

I had an infinite scroll page on my website. It was working just fine but now, I see that it doesn't load the first instance immediately on the page load. But when scrolled down, appears and infinite scroll also works.

I haven't imported anything or changed anything but suddenly happened on all browsers at the same time.

So is it related to any updates? And anyone has an idea how to resolve this? Here is the related javascript that loads the page as scrolled down.

 <script type="text/javascript">
        function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    });
    return vars;
}

            var start = 0;
            var limit = 20;
            var reachedMax = false;
            var dnmID = getUrlVars()["donemID"];
            var dvltID = 0;

            $(window).scroll(function () {
                if ($(window).scrollTop() == $(document).height() - $(window).height() )

                    getData();
            });

            $(document).ready(function () {
               getData();
            });

            function getData() {
                if (reachedMax)
                    return;

                $.ajax({
                   url: 'collection_data.php',
                   method: 'POST',
                    dataType: 'text',
                   data: {
                       getData: 1,
                       start: start,
                       limit: limit,
                       dnmID: dnmID,
                       dvltID: dvltID,
                   },
                   success: function(response) {
                        if (response == "reachedMax")
                            reachedMax = true;
                        else {
                            start += limit;
                            $(".results").append(response);
                        }
                    }
                });
            }
        </script>
  • 1
    Any error you get in developer console? (F12) - Edit: Furthermore, enable error reporting in collection_data.php, and in the getData success function, use: console.log(response); – Andrew Aug 02 '19 at 07:47
  • aha. There is a warning saying: [Warning] [blocked] The page at https://xxxxxxx.com/collection2.php?&donemID=2 was not allowed to run insecure content from http://code.jquery.com/jquery-3.2.1.min.js. (collection2.php, line 8) – Yigit Altay Aug 02 '19 at 07:50
  • Try changing your jquery include to https version then, see what happens: - Edit: SO removes the https from comments, but make sure it's there. – Andrew Aug 02 '19 at 07:52
  • it cleared the warning but there is an error message looking like this: https://imgur.com/C1VZwc7 – Yigit Altay Aug 02 '19 at 07:58
  • So there is a javascript error, but it doesn't seem to be with the code in your post. Check out countdown.js line 20 - 53, called from scripts.js line 204, and look for an undeclared variable with the name of "interval", or maybe some minor syntax error. If you can't find anything, update your post with the above codes and their surroundings. – Andrew Aug 02 '19 at 08:03

0 Answers0