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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:15:37+00:00 2026-06-14T20:15:37+00:00

I am using .load() extensively for AJAX content. It’s great but I would like

  • 0

I am using .load() extensively for AJAX content. It’s great but I would like it if it did a little more:

  1. If, in response to user actions, I make multiple calls to .load() on the same div, I can end up with the wrong data in the div. This happens when an earlier request is slower to callback than a later one. I need something to reject out-of-date callbacks

  2. It would be nice if .load() added a CSS class to the target… and removed that class after callback completed.

Is there a library or plugin for jQuery that offers such functionality? Or can it be done in so few lines that it’s not worth a plugin?

  • 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-14T20:15:37+00:00Added an answer on June 14, 2026 at 8:15 pm

    It’s super easy to create your own plugin that prevents multiple concurrent requests. Here’s a simple plugin that intercepts AJAX calls, keeps a list of outstanding requests and aborts them when a new one comes in:

    $.fn.preventConcurrentAjax = function() {
        return this.ajaxSend(function(e, jqXHR, settings) {
            $.each($(this).data("pca-pending") || [], function() { this.abort(); });
            $(this).data("pca-pending", [jqXHR]);
        });
    };
    

    You can easily extend this so that it cancels earlier requests that are still outstanding when a request completes instead of when one is queued; to do this you will also need to store a timestamp with each request.

    You can also use jQuery’s .ajaxStart() and .ajaxStop() to trivially automate toggling a “loading” class, for example:

    $.fn.loadingOnAjax = function() {
        var $self = $(this);
        return this.ajaxStart(function() { $self.addClass("loading"); })
                   .ajaxStop(function() { $self.removeClass("loading"); });
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im using .load to load content into a div, i would then like to
I am using .load() in jQuery to load in html content, but in this
Im using .load() to populate a div with new content but when I do
When using jQuery.load to dynamically load HTML content into a webpage, what is the
I am using jQuery ui in a rails application. I want to load content
I'm trying to load only a div from a page using .load(), but as
So I am using load functions of jQuery to use ajax on my pages.
I am using .load() function to load html content from a controller action and
I have a script that loads content using load() via a click function. I'd
I'm using .load() method to get some data on ('document').load() event, but i'm not

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.