Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:17:59+00:00 2026-06-11T04:17:59+00:00

hi am having a problem with infinite scroll functionality, when all the contents have

  • 0

hi am having a problem with infinite scroll functionality, when all the contents have been displayed it still continues to scroll (strange behavior). i am looking for a way to stop the infinite scroll when all contents are displayed

here is my code

<script type="text/javascript">
jQuery(document).ready(function ($) {
(function () {
  var page = 1,
    loading = false,
    finish = false;


  function nearBottomOfPage() {
    return $(window).scrollTop() > $(document).height() - $(window).height() - 200;
  }

  function finish() {
    finish = true;

  }
  $(window).scroll(function () {
    if (loading) {
      return;
    }
    if (nearBottomOfPage() && !finish) {
      loading = true;
      $('#loader').show();
      page++;
      $.ajax({
        url: '/office?page=' + page,
        type: 'get',
        dataType: 'script',
        success: function () {
          $('#loader').hide();
          loading = false;
        }
      });
    }
  });
}());

})

here is what i tried

 <script type="text/javascript">
 jQuery(document).load(function($) {
 function scrollfn (event) {
if (loading) {
  return;
}
if (nearBottomOfPage() && !finish) {
  loading = true;
  $('#loader').show();
  page++;
  $.ajax({
    url: '/office?page=' + page,
    type: 'get',
    dataType: 'script',
    success: function () {
      $('#loader').hide();
      loading = false;
      $(window).unbind('scroll',scrollfn);
    }
    });
   }
   }

  $(window).bind('scroll',scrollfn);
 })
 </script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:18:01+00:00Added an answer on June 11, 2026 at 4:18 am

    You never do call your “finish” function.

    Call finish(); in your success ajax callback

    If doesn’t work try 3 things:

    1) I think your function checking for being nearBottomOfPage() is not correct (see my answer here for correct version: Calculating end of scroll on a web page) –> also try disabling all styles on your page too. If you have any negative margins or negative padding it will screw up your scroll detector calculation.

    2) Forget temporarily about your nearBottomOfPage() – I mean try changing your code from if (nearBottomOfPage() && !finish) to just if (!finish) — if your finish call works then, you are definitely having a problem about nearBottomOfPage() as I said above in #1

    3) If even with item #2 change it is still not working try to separate out your bound callback out of anonymous function into a separate function for more control over it, so you can unbind that callback later, like this:

    function scrollfn (event) {
        if (loading) {
          return;
        }
        if (nearBottomOfPage() && !finish) {
          loading = true;
          $('#loader').show();
          page++;
          $.ajax({
            url: '/office?page=' + page,
            type: 'get',
            dataType: 'script',
            success: function () {
              $('#loader').hide();
              loading = false;
              $(window).unbind('scroll',scrollfn);
            }
          });
        }
      }
    
    $(window).bind('scroll',scrollfn);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi am having a problem with infinite scroll functionality, when all the contents have
Im having problem in my UIscrollView ,this is what I have done: Whenever a
I'm having problem with datagrid view. I have attached an image with the code
hello I am having problem related to https:// . I have used FB.getLoginStatus(function(response) function
I am having a problem understanding which function runs (probably in infinite loop) in
I'm having a strange problem while attempting to transform a blocking socket server into
Im learning Java and having a problem with ArrayList. Firstly I have a class
I'm working on a site http://www.infinite-possibility.com/ which is currently having a problem with any
I have the following problem, and am having trouble understanding part of the equation:
I'm having a problem with my rake task hanging in an infinite loop. So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.