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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:41:43+00:00 2026-05-10T21:41:43+00:00

This question deals with concurrency issues, for suggestions on how to display a busy

  • 0

This question deals with concurrency issues, for suggestions on how to display a busy icon see this question: Javascript – loading/busy indicator or transparent div over page on event click

When a user initiates an AJAX request on a page it’s useful to show some kind of ‘working’ or busy icon or progress indicator. If there is only one long-running process this can be handled in a relatively straightforward way:

function do_action() {    show_busy_icon();            long_running_asynchronous_process(function() {       // Callback function run when process finishes       hide_busy_icon();    }); } 

However, if multiple asynchronous processes are running on the page, using on/off methods wouldn’t work. The first process to finish switches off the icon even though there are additional processes running.

So, how do you handle displaying an indicator, on a web page, that is on when there are one or more processes running, and off when there are no processes running?

I imagine it would be possible to maintain a count of the number of processes running. hide_busy_icon() only hides the icon if the process count is 0. That seems kinda prone to failure. Perhaps there’s a better/simpler way that I’m not seeing.

Thanks for your ideas and suggestions!

Edit: After working with the solution in the marked answer for a while, I’m happy to say it works very well. The only issue I’ve run into are cases where my own scripts call functions of scripts I don’t control. Unless those functions allow callbacks to be supplied there’s no way to update the process-count when they begin and end.

An example of where this can occurs is adding a set of markers to a Google map. Once my script calls the Google maps function the busy icon disappears, while the markers are still being loaded.

I’m not sure of a good way to handle this.

  • 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. 2026-05-10T21:41:44+00:00Added an answer on May 10, 2026 at 9:41 pm

    If you want the same busy indicator for all actions, then use a counter.

    Instead of ‘show_busy_icon()’, do a ‘increment_busy_count()’, which calls ‘show_busy_icon()’ if busy count goes from 0 to 1. Instead of ‘hide_busy_icon()’, do a ‘decrement_busy_count()’, which calls ‘hide_busy_icon()’ if busy count goes from 1 to 0.

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

Sidebar

Related Questions

This question deals with CoffeeScript but the same issues still apply to JavaScript. Consider
I know this SO question, but it deals with the subject in more general
This question is similar in concept to this one , except I see I
This question deals with optional arguments passed to a Ruby block. I'm wondering if
This question deals with teamwork and emails. I'm facing the following scenario. I have
My question deals with this UI sample. Having trouble with approach to managing the
NOTE: This question deals with an issue observed back in 2011 with an old
This related question deals with the retrieval of an app's build date in C#,
The other answers to this question deal with timing whereas with this problem deals
Passing a Enum value as a parameter from JSF This question already deals with

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.