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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:55:44+00:00 2026-06-17T08:55:44+00:00

I have this code: $(window).scroll(function () { if ($(window).scrollTop() >= $(document).height() – $(window).height() –

  • 0

I have this code:

$(window).scroll(function () { 

    if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {

        var site_url = $("#site_url").val();
        var post_url = site_url+"index.php/ajax/get_more_users";
        $("#loading_more_users").show();
        var users_page = $("#users_page").val();


        //alert("y");
        $.post(post_url, {'page': users_page}, function(data){              
                //alert("x");
            $("#loading_more_users").hide();
            $("#left_members_collumn").append(data);
            $("#users_page").val(eval(Number(users_page)+1));


        });

   }
});

Anyone can tell me why the $.post are executed once, twice or three times when I scroll bottom? I get the duplicate content. The main function is executed fine, but I don’t know why there are multiples ajax requests.

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-17T08:55:45+00:00Added an answer on June 17, 2026 at 8:55 am

    The scroll is firing multiple times with criteria that satisfy your if condition. What you can do to prevent this is set a bool to indicate your are posting, so you don’t post twice:

    var isPosting = false;
    $(window).scroll(function () { 
    
        if (!isPosting && $(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
            isPosting = true;
            var site_url = $("#site_url").val();
            var post_url = site_url+"index.php/ajax/get_more_users";
            $("#loading_more_users").show();
            var users_page = $("#users_page").val();
    
    
            //alert("y");
            $.post(post_url, {'page': users_page}, function(data){              
                    //alert("x");
                $("#loading_more_users").hide();
                $("#left_members_collumn").append(data);
                $("#users_page").val(eval(Number(users_page)+1));
                isPosting = false;
    
            });
    
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code. $(document).ready(function() { $('#box').hide(); $(window).bind('scroll', function(){ if($(this).scrollTop() > 200) { $(#box).fadeIn(300);
I have the following code: $(document).ready(function(){ $(window).scroll(function(){ Topo = $(window).scrollTop(); ObjScrollASoda.css({ 'marginTop' : (Topo
I have got this code: function init(){ if (typeof window.jQuery !== 'function') { var
I have this code: $(document).ready(function() { var number = 10; var offset = 10;
I have this code inside a iframe: window.addEventListener('message', function(e){ if(e.data == 'test') console.log(e); },
I have this form submit code: Event.observe(window, 'load', init, false); function init() { Event.observe('addressForm',
I have some html5 postMessage code: window.addEventListener(message, FA.recieveMessage, false); That listener invokes this function:
I have an infinite scroll set up with the following piece of code. $(window).scroll(function
I have this code: public class Window extends JFrame { public Window(){ ... JButton
I have this code which draws a Window and NSView, and have set up

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.