Boris
Boris

Reputation: 159

Loading animation freezes in IE7 and sometimes in IE8 when making an async ajax call

I am using a animated gif to be shown when sending an asynchronous request to a web service via jQuery.ajax(). The gif is initially hidden (display: none) and shown via .show() right before the request is sent.

It does work as expected in Chrome, FF, and IE9 and looks just fine, but in IE8 its animation freezes from time to time in the process and in IE7 just shows the gif but does not animate at all.

I have searched through multiple threads regarding this problem, but they were quite outdated (as are IE7 and IE8, I know. But sadly we still have to fully support those browsers) and the consens seemed to be: Not possible - IE7 has only one thread to run JS and animated gifs.

I am hoping, that enough time has passed and their exists a workaround for this problem. I'm quite new to JS and web development, so chances are, I just don't have enough experience to find a simple solution, that everyone else knows already. :)

Thanks in advance, Boris

Upvotes: 2

Views: 1586

Answers (2)

Rohan
Rohan

Reputation: 1805

Try removing the display:none attribute using jquery.

$("#id or .class").css("display", "block" );

or

$("#id or .class").removeAttr("display");

The same issue happened with me and one of the above worked. :)

Upvotes: 1

Manuel van Rijn
Manuel van Rijn

Reputation: 10305

you could try to do the ajax call in the callback of the show so:

$(".gif_element").show("normal", function() {
    $.ajax({})
});

of course this is a workarround

Upvotes: 2

Related Questions