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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:50:28+00:00 2026-05-31T10:50:28+00:00

What I am trying to do is append a loading image to a div

  • 0

What I am trying to do is append a loading image to a div (so the user knows something is loading) and then I call a jquery ajax function, which is set to “async: false”. Here is my code:

$jQuery("#playersListDiv").html(loadingImage);    
$jQuery.ajax({
         type: "POST", /* this goesn't work with GET */
         url: urlValue, /*ex: "NBAgetGamesList.php" */
         data: parameters, /*ex: "param1=hello" */
         cache: false,
         async: false,
                     success: function(data){

                     }
});

The problem is that the browser locks and does not append the loading image until AFTER the ajax call is done which is useless of course. Firefox is the only browser that actually appends the loading image. IE, Chrome, and Safari DO NOT append the loading image.

I know browser locking happens because async is set to false but this is my only option because I have to wait for this request to complete before continuing because I need the data that is returned.

Is there any way around this? If I place an alert after the I append the loading image that works but I don’t want an alert popping up every time.

  • 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-31T10:50:29+00:00Added an answer on May 31, 2026 at 10:50 am

    Despite your assertion to the contrary you don’t need it to be synchronous. Whatever you need to do with/after the response can be done in the success (and/or error or complete) callback. So change:

    $jQuery("#playersListDiv").html(loadingImage);    
    $jQuery.ajax({
       ...
       async: false,
       ...
    });
    // OTHER CODE
    

    to be like this:

    $jQuery("#playersListDiv").html(loadingImage);    
    $jQuery.ajax({
       ...
       async: true,
       success: function(data) {
          // OTHER CODE
       }
    });
    

    Or move “OTHER CODE” to a separate function that you call from the success callback.

    If you need something more complicated than that you could encapsulate the above in a function and pass a callback to it:

    function doAjaxStuff(callback) {
        $jQuery("#playersListDiv").html(loadingImage);    
        $jQuery.ajax({
           ...
           async: true,
           success: function(data) {
              // optional other processing here, then:
              callback(data);
           }
        });
    }
    
    // then from somewhere else in your code:
    doAjaxStuff(function(data) {
       // do something with data
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm loading an image exteranlly via ajax like so... function load_image(image_href) { var img
I am trying to create a dynamic set of dropdown boxes, using jQuery/AJAX and
Im trying to call a js function on a HTML element which I have
I am trying to append an image after the last input field in a
I am am trying to append an element to a <div> of a page,
I'm loading and inserting html-code using Jquery Load() method. But when I'm trying to
i'm trying to load data into an element using jQuery.get. After loading is completed,
I'm trying to append a div to the colorbox modal, and what I did
I am trying to use a jQuery based Photo Stack which uses the following
After trying to append some code to a div layer I received the following

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.