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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:44:14+00:00 2026-05-31T18:44:14+00:00

I have an ajax loader much like this one: $(‘#loadingDiv’) .hide() // hide it

  • 0

I have an ajax loader much like this one:

$('#loadingDiv')
    .hide()  // hide it initially
    .ajaxStart(function() {
        if(showSpinner == true){
            $(this).show();
        }
        else{
            showSpinner = true;
        }
    })
    .ajaxStop(function() {
        $(this).hide();
    })
;

from: How to show loading spinner in jQuery?

edited after updates

I initialize showSpinner = true, and set it to false immediately before my recurring ajax call. It works most of the time but sometimes the spinner won’t show up when its supposed to. I’ve polled the value of showSpinner and it looks like it remains false for too long between when its set and when it’s set back to true.

It works wonderfully, but I also have a recurring ajax call that is executed every 15 seconds, and I don’t want the ajax loader to appear for that one. I’ve tried this:

showSpinner = false;

// make ajax call to the database to check for new photos
$.ajax('/url', {
    type:"post",
    data: data,
    success: function(response){
    }
});  

and it will prevent the spinner from appearing, but sometimes it disables the spinner for the other ajax calls too (other times it works fine). I’ve tried moving the re-enabling of the spinner to beforeSend but it didn’t help. When the setInterval call that executes the code above is removed, it fixes the problem.

My other option is to include the spinner every place an ajax call occurs, but I’d prefer the more generic solution. Does anyone know how to get around this?

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-05-31T18:44:14+00:00Added an answer on May 31, 2026 at 6:44 pm

    This sounds very similar, if not identical, to my own question about disabling certain ajax event handlers. This answer may be useful to you.

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

Sidebar

Related Questions

I have this in my theme's function file: $(document).ready(function() { $(.ajax-loader).attr(src,<?php bloginfo('template_url'); ?>/images/ajax-loader.gif); });
I have problem with ajax loader image when I use the load() function, the
I would like to have Ajax form in Rails so i'm using form_remote_tag. The
I have $.ajax({ url: identity, success: function(data) { ProcessIdentityServer(data) } }); When 'data' is
I have put together a script which is very much like the flickr photostream
I have a loader animated gif that I want to hide and show during
I have a php page. This has multiple images which looks like tabs. With
i have a jquery ajax request. On page load a loading-image is displayed. this
I have a code for a comment system. jQuery: function sendComment() { $('#comment_write_area').fadeOut(1); $('#ajax-json-response').fadeOut('fast').html('');
The problem. I have multiple tab, their content is loaded via ajax, so the

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.