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 9254727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:32:39+00:00 2026-06-18T11:32:39+00:00

I implemented a load function which is getting triggered whenever one reaches end of

  • 0

I implemented a load function which is getting triggered whenever one reaches end of the page. It’s working basicly, but the event gets triggered numerous times, whenever I scroll down. is there a better way to implement this idea or a way to not trigger this event numerous times?

Here’s what I did:

var loading = false;
$(window).scroll(function(){
    if((($(window).scrollTop()+$(window).height())+250)>=$(document).height()){
        if(loading == false){
            loading = true;
            $.get("test", function(data){
             $("div.article:last").after(data);
});
            loading = false;

        }
    }
});
   $(document).ready(function() {
    $('#loaded_max').val(500);
});

Thank you!

  • 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-18T11:32:40+00:00Added an answer on June 18, 2026 at 11:32 am

    You do this:

    $.get("test", function(data){
        $("div.article:last").after(data);
    });
    loading = false;
    

    The loading=false; is outside your $.get callback function. The $.get is a async function which means. loading=false;is executed directly after your $.get and not when your Ajax call is ready.

    If you put your loading=false; inside your $.get callback. You won’t have multiple requestst at the same time.

    Solution to get only 1 request at a time:

    $.get("test", function(data){
        $("div.article:last").after(data);
        loading = false;
    });
    

    Also I would start loading the next part of the page like 400px before people reach the bottom. So they can keep on scrolling and don’t have to wait for your request to be ready. I’ts more smooth that way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented below function in a separate .js script file which I load
I have implemented Infinite scrolling(i.e Load records when the scrollbar reaches the bottom of
I am trying to get a default query to implement upon page load but
I'm trying to implement a function which would load a server-stored CSV file, and
I have the following function which is for ajaxing in a page and the
For an Android application, I have implemented an external function in C, which I
I want to display an element(calling fadeIn function) when click event is occured. But,
I've implemented a recursive function which takes as parameter a numpy array. Here the
Implemented a generic repository with several Methods. One of those is this: public IEnumerable<T>
We implemented In-app Billing one year ago with no problems following the sample code

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.