Phase2Results.php" ); ?> Synchronous XHR Enhancements - RuntimeWiki

Synchronous XHR Enhancements

From RuntimeWiki

Jump to: navigation, search



Synchronous XHR enhancements

Detailed write-up


Fetching data from the server using XHR is the core of Ajax. A number of frameworks (including DWR, GWT and Jaxer) offer RPC style encapsulation of XHR to expose server API functions in the browser. Currently the only safe way of using XHR is asynchronous mode which leads the programmer into callback style solutions. In some situations it is more natural to make a blocking call and have the call return the received value, but this synchronous-style XHR is currently plagued with the risk of locking up the user's browser window forever as there is no timeout used in waiting for data from the server.

Several current frameworks (including Jaxer) use synchronous XHR.

Why Is This Important?

Being able to use synchronous/blocking XHR (without the current risks) would allow for less complex code and in some cases a more natural style of coding RPC-oriented algorithms.

Also, synchronous XHR is the most dependable way of sending a request to the server at page unload, as its blocking nature will make the page wait with its unloading until a reply from the server is received. (The aim of this request could be saving data, unlocking a record, tearing down some server-side browser-window related data structure etc)

Possible solution

Implement all below:

1. Add a timeout property to the XMLHttpRequest object that controls how long an XHR call will wait for the server before aborting the call and returning null or exception.

2. Improve handling of UI events during a sync XHR so UI gets repainted when needed and animated GIFs are run. This is explained in more detail in Browser Unresponsive Mode Enhancements

What exists today?

Background material that request this feature

Better handling of sync XHR is also discussed in JavaScript Coroutine Support and Browser Unresponsive Mode Enhancements.


In this section, the contributors should express their opinions about this feature request, such as providing particular technical analysis or describing in prose why this feature is important (or not). It is recommended that each contributor create his own level-3 sub-section

Jon Ferraiolo comments

Seems like a good request. High value/cost ratio and already supported by one of the browsers.

I don't see the timeout feature from IE8 in the latest editor's draft of XMLHttpRequest v2 (, although they have added mention of timeout errors in the section on network errors.

Phase I Voting - Vote for Your Top 5 Features


(2008-04-01) We have now changed the voting procedure. Instead of putting votes on each separate wiki page, we are asking people to cast their Phase I Votes on the following wiki page:

Phase II Voting

More about this later.

Personal tools