tags:

views:

451

answers:

2

When an user tries to send AJAX requests simultaneously from multiple browser tabs, the earlier requests get completed and the page loads but the other AJAX calls are preempted. AS a result of which the response is empty for the other calls. Only one call survives. In my application using struts 2.0, JSP and javascript and the prototype framework, i found that the server response is empty in the cases mentioned above though the data gets updated in teh database with the request parameters. The onSucess event handler for Ajax.request gets called but the the response is empty.

Can you please help?

Thanks

A: 

I think we should get ready status from Ajax call before starting making another call to server (except you were creating a new ajax object for each call), but i could be wrong.

I never use prototype, but i use Adobe Spry for years and have no problem with multiple Ajax call, but this one is for prototype, read this it should helpful.

Multiple Ajax Requests

Dels
Thanks for the reply! I dont think i can use an external lib in my app, unless there is no other way.... Can you please help?
try to make a new Ajax Object when you create a new Ajax request, or simply... create Ajax Objects for each tab (Ajax request)
Dels
A: 

I'm not quite sure what's happening to cause this, but here's one thing to try: The last large AJAX-centric application I developed, we had to add a random number parameter to each query string to ensure there was no caching on either the client or server side (or ISP side, these days).

Guaranteeing the query URL is different in each tab could solve your problem.

dj_segfault
as long you create a new Ajax Object for each call then it should have no problem, cache busting needed for browser like IE, but it was very good idea to get up-to-date response
Dels
Thanks for the reply! Each tab i believe while executing teh javascript will create a new Ajax request object. The request goes fine, updates, is succesful but the response is null. i saw in firebug that the req was correct but resp is empty...
@Bindi: yes the tab will create a new Ajax request, but not a new Ajax object
Dels