Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading gif image is not showing in IE and chrome

I am using JQuery ajax call for sending synchronized call to server and want to display a loading image for that time.

But loading image is visible in Firefox but not in IE and chrome. When i debug, i found that in IE, when we call java script, it stop showing changes in browser as it halts DOM and when the call is completed, it then shows all the changes. Since i shows the loading image on ajax call and remove it after completing the call, the IE doe not display any image.

But when i use alert box,it shows the loading image in IE as it stop the thread until we response to it.

Is there any method to stop java script execution for a millisecond such that IE execution halts and loading image is shown.

I already tried ajaxSend, ajaxComplete, ajaxStart, ajaxStop of JQuery and timer event of java script, but does not get any solution.

Any help is precious, thanks in advance.

like image 525
Mohit Pandey Avatar asked Aug 14 '12 06:08

Mohit Pandey


People also ask

Does all browsers support GIFs?

Bookmark this question. Show activity on this post. It's seems like all major browsers (ie, firefox, safari, chrome) support animated gifs.


1 Answers

In the context of XHR, synchronously means just that the browser freezes until the request is complete. If what you want is to make sure only one request is running at a given time, then use your own flag to indicate that a request is in progress.

By definition, the synchronous flag of a request means that any other activity must stop. I'm surprised that it even works in Firefox, last time I tried that it didn't work, but that was a long time ago. So forget about it, there's no way to make it work in all browsers. Even if you delay the request using a setTimeout, at best you'll get a frozen browser with a non-animated gif. And users don't like when you freeze their browser, especially if the request might take more than a fraction of a second.

Don't ever depend on the browser for security or correct functionality related features. If your application might get broken if a client does two requests in parallel, then you have a bug on the server side. There's nothing that prevents a malicious user from making parallel requests using other tools than the normal UI.

like image 186
Sergiu Dumitriu Avatar answered Oct 04 '22 19:10

Sergiu Dumitriu