0

I am writing a simple dojo based application in which I show some 'in-progress' messages and spinners on UI (jsp) with setTimeout(clearMessage()) methods to show the message for sometime.

On Firefox, for the time, the xhrGet call goes to the server and returns, this message gets shown to the user that the operation is in progress. Once the operation responds with status, the message gets updated as "Operation done successfully".

But On IE, I see that once the xhrGet call is sent, the IE UI freezes till the response comes back from the server. As a result of this behavior, my 'In-Progress' messages are not coming up on IE at all.

I also read some comments that some browsers could freeze this way for synch calls at Ajax call freezes UI in internet explorer but works fine in firefox. Is there a way, where I could get my 'In-Progress' messages displayed on IE as well, while retaining the synch:true attaribute of xhrGet?

Any help here is appreciated?

Thanks in advance.

Community
  • 1
  • 1
Shankar
  • 13
  • 4
  • Some code samples might help, to be honest I'm not sure why it's working in FireFox, since it's single threaded as well, which is why synchronous xhr is considered a pretty bad practice... – Frances McMullin Jul 10 '13 at 10:37
  • Is there a good reason why you want sync:true ? Unless it's an ajax call fired before page unload, I can't see a practical use case... Also, what dojo version are you using ? – Philippe Jul 10 '13 at 14:45
  • Hi Phillippe, we use Dojo 1.8. The case is that the user fires an operation from the UI,whose response the UI is waiting for, and I didn't want user to be free to do any other operation meanwhile. If he does so, the previous operation's response cannot be shown to him/her, the newer one's response will override the response area. – Shankar Jul 12 '13 at 09:55

1 Answers1

0

You should never, ever, use XmlHttpRequest in synchronous mode. Doing so responsible for a huge percentage of hangs and forced-closures of the browser: https://web.archive.org/web/20111103102354/http://blogs.msdn.com/b/ieinternals/archive/2011/08/03/do-not-use-xmlhttprequest-in-synchronous-mode-unless-you-like-to-hang.aspx. That's because Sync mode blocks the UI thread until the HTTP response is returned; the UI thread is where JavaScript runs, as well as where UI updates and responses to user-input events are generated.

Instead, you should write your code in Async mode and use callbacks to update the UI when the response is returned.

EricLaw
  • 56,563
  • 7
  • 151
  • 196