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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:28:31+00:00 2026-06-07T22:28:31+00:00

I have a page with 2 separate forms that can be submitted via Ajax

  • 0

I have a page with 2 separate forms that can be submitted via Ajax (jQuery). For each of these forms I’d like to show a loading indicator to the user. I have found a nice piece of code that can easily show these icons, but it only works when there’s 1 form.

$('.ajaxloader').hide().ajaxStart(function () { 
    $(this).show(); 
}).ajaxStop(function () {
    $(this).hide(); 
});

ajaxloader is a class which shows the loading image as a CSS background image. To use it, I just need to add something like: <span class="ajaxLoader">Busy ...</span>

When I test this with my page (that has 2 forms), and I submit one of the two, then both loading indicators appear (which is quite obvious). Now my question is, how can I show the indicator that needs to be shown? I was thinking about giving the span-tag an id attribute, but then I don’t know how to proceed. I want this to be as generic as possible, so I don’t have to hardcode and duplicate code a lot.

Thanks!

  • 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-07T22:28:33+00:00Added an answer on June 7, 2026 at 10:28 pm

    You could attach the “show loading indicator” callbacks to the Ajax queries themselves, not do a ‘catch-all’ like your current solution.

    Something like this in your $.ajax() call:

    $.ajax("/form1/target", {
        beforeSend: function() {
            $(".ajax-loader-1").show();
        },
        complete: function() {
            $(".ajax-loader-1").hide();
        }
    });
    

    (And a similar one for your second form, wherever the Ajax call for that is defined)

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

Sidebar

Related Questions

I have a php page with 3 different forms. I create 3 separate print
I have a website about festivals, with a separate page for each festival. Normally,
I have a .aspx page that loads three separate .ascx controls to represent adding,
In my web application I have a user profile page. That page has these
I have a page with multiple forms (2 forms) on that page. There is
I have a form that performs 3 separate tasks when submitted. When the form
Hi I have one separate page for footer as footer.html & I want to
I have some the page elements split into separate visual blocks. I am currently
I have 2 functions on a seperate page that I am including of the
I have page where I use model which can have different types (depending by

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.