Home > Uncategorized > Should we use Synchronous XMLHttpRequest

Should we use Synchronous XMLHttpRequest

In one of our earlier posts, Synchronous calls with XMLHttp request , we had displayed a code sample on how to make the call.

So why do we chose synchronous over asynchronous ?

There are situations in which you would like to use Synchronous  XMLHttprequest because the page rendered depends upon the data received . If we do not have the data we will have wait for the data to come back .  hence some user take the route of making synchronous  requests.

But when we were reviewing our design decisions, there was some though on Should we be using synchronous XMlHttprequest ?

While going through Mozialla site , I  found this

Note: You shouldn’t use synchronous XMLHttpRequests because, due to the inherently asynchronous nature of networking, there are various ways memory and events can leak when using synchronous requests.

Also the AJAX patterns recommend

In practice, XMLHttpRequest calls should almost always be asynchronous. That means the browser and the user can continue working on other things while waiting for a response to come back

Based on this information, I think it would be wise to use asynchronous request. Any suggestion ?

Reference :


Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.