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

  • Home
  • SEARCH
  • 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 3400340
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:52:52+00:00 2026-05-18T04:52:52+00:00

I have an app that has several different types of form elements which all

  • 0

I have an app that has several different types of form elements which all post data to the server with jQuery AJAX.

What I want to do is:

  1. Show a loader during AJAX transmission
  2. Prevent the user from submitting twice+ (clicking a lot)

This is easy to do on a one off basis for every type of form on the site (comments, file upload, etc). But I’m curious to learn if that is a more global way to handle this?

Something that’s smart enough to say:

  1. If a form is submitting to the server and waiting for a response, ignore all submits
  2. Show a DISABLED class on the submitted / clicked item
  3. Show a loading class on the class="spinner" which is closest to the submit item clicked

What do you think? Good idea? Done before?

  • 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-05-18T04:52:52+00:00Added an answer on May 18, 2026 at 4:52 am

    Take a look at the jQuery Global Ajax Event Handlers.

    In a nutshell, you can set events which occur on each and every AJAX request, hence the name Global Event Handlers. There are a few different events, I’ll use ajaxStart() and ajaxComplete() in my code sample below.

    The idea is that we show the loading, disable the form & button on the ajaxStart() event, then reenable the form and hide the loading element inside the ajaxComplete() event.

    var $form = $("form");
    $form.ajaxStart(function() {
         
        // show loading
        $("#loading", this).show();
    
        // Add class of disabled to form element
        $(this).addClass("disabled");
    
        // Disable button
        $("input[type=submit]", this).attr("disabled", true);
    });
    

    And the AJAX complete event

    $form.ajaxComplete(function() {
    
        // hide loading
        $("#loading", this).hide();
    
        // Remove disabled class
        $(this).removeClass("disabled");
    
        // Re-enable button
        $("input[type=submit]", this).removeAttr("disabled");
    });
    

    You might need to attach to the ajaxError event as well in case an AJAX call fails since you might need to clean up some of the elements. Test it out and see what happens on a failed AJAX request.

    P.S. If you’re calling $.ajax or similar ($.getJSON), you can still set these events via $.ajaxStart and $.ajaxComplete since the AJAX isn’t attached to any element. You’ll need to rearrange the code a little though since you won’t have access to $(this).

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

Sidebar

Related Questions

I have a small app that has a Render thread. All this thread does
I seem to have an app on my Dev server that has lots of
I have a rails app that has picked up a bit of traction, but
I have an existing app that has many, many models. I'd like to log
This is an interesting conundrum. We have a WPF app that has a Vista-like
I have a standalone Java app that has some licensing code that I want
I have a Cocoa app I'm writing that has an ImageView with a TextView
I have a Windows Forms app, that has a single ElementHost containing a WPF
I have an app that executes commands on a Linux server via SSH just
I have an app that needs to open a new window (in the same

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.