Saturday, April 30, 2011

AJAX calls from multiple browser tabs at the same time:

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

From stackoverflow
  • 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 : try to make a new Ajax Object when you create a new Ajax request, or simply... create Ajax Objects for each tab (Ajax request)
  • 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.

    Dels : 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 : @Bindi: yes the tab will create a new Ajax request, but not a new Ajax object

0 comments:

Post a Comment