Ajax tip of the day - Concurrent Connections

Concurrent Connections with Ajax

Here is an quick example of an ajaxed application - you have your main page (lets say index.htm) and when it loads it calls in various content using ajax (lets say we call in navigation.php, products.php and basket.php). Ok 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.

Ok, so how do we get around this limitation? well one way I’ve found that works pretty well is to put 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.

Bookmark on del.icio.us Bookmark      Digg This Digg it

1 Comment

  1. necroman08 said,

    May 29, 2008 @ 2:40 am

    Can this be solved by adding false to xmlHttp.open
    xmlHttp.open(”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?

RSS feed for comments on this post

Bad Behavior has blocked 860 access attempts in the last 7 days.