Concurrent Connections with Ajax

Here’s an quick example of an ajaxed application with multiple connections.

You have your main page (lets say index.htm), when it loads it calls in various content using ajax
(lets say we call in navigation.php, products.php and basket.php).

So navigation.php, and products.php load fine but basket.php fails!!

Hmmm, what a pain – why did it fail to load you ask. Simple!! most browsers can only handle 2 ajax calls at one time and because all 3 of them are called on the index.htm page load – then one probably will fail.

How do we get around this limitation? one way I’ve found that works pretty well is to put a delay in the ajax calls

window.setTimeout(“ajaxcall()”, 400); ” for example.

You could have this in the <body onload=”"> tag or just simply enter the javascript at the end of the page
(body onload would probably be the best option).

I’d be interested to hear other possible solutions.

1 Comment on Ajax tip of the day – Concurrent Connections

  1. necroman08 says:

    Can this be solved by adding false to“GET”,url,false);
    so the call i synchronoss instead of asynchronoss as default, and the execution of code waits until the call is completely done?