views:

383

answers:

2

I'm using XMLHTTPRequest binding to receive asynchronous events from the server. XHR opens a server URI and then hangs until an event comes or timeout occurs, in any case JS fires a new XHR on the same URI immediately.

This works fine, but there is an annoying problem in Safari and Chrome: both keep showing "page loading" animation while any XHR is active. Chromes goes even further and keeps animating cursor, effectively making the application unusable.

Is there any way to disable this behaviour? I believe this is done intentionally for security reasons, so user could always know if page is loading anything. Still, both FF and IE treats XHR differently.

A: 

I think this happens for sync request to a URI. You many want to try an async request. I think they are treated differently.

Nick Berardi
thank you, will try that out immediately
Alexey Naidyonov
negative. we've been using asynchronous xhr already. so the problem's still there.
Alexey Naidyonov
Positive! (Couldn't resist) Don't know then. This doesn't occur when using other frameworks such as jQuery and Yahoo. Also if the page hangs until an event comes or timeout occurs that is sync functionality not async. I would double check your code to make sure it doesn't stall the page, because that is probably what is causing the loading signals to occur.
Nick Berardi
+2  A: 

The animated loading indicator means that the page load is in progress. This may happen for series of XHR, directly started from window.onload() event handler. If these XHR calls will be wrapped into setTimeout() call, the page loading will be finished with binding to asynchronous events listening.

Alex Pavlov
Precisely. Thank you!
Alexey Naidyonov
In a UIWebView on iPhone, the setTimeout method works only if the delay is large enough (around ~100ms). Otherwise I still get the spinner :(
Jaka Jančar