skip to main | skip to sidebar

May 23, 2008

Adventures in Ajax

My current project has me doing some hand coded Ajax (by which I mean that I'm not using an Ajax library). There are a couple of interesting findings I'd like to mention to anyone out there who might be doing the same.

As I watched the http requests (courtesy of "Charles") I notice that IE6 allowed only 2 concurrent Ajax requests and that Firefox allowed a maximum is 3. The impact of this is if you have several XMLHttpRequest objects processing requests (each object can only process 1 request at a time) you could have one or more ajax calls in queue. This might be important if you have slow response times or several different pieces of functionality making Ajax calls.

Another thing that I discovered is that while the async parameter for does not have to be specified, it actually defaults differently depending on the browser; in IE6 the default is true, but in Firefox the default is false. Not specifying this parameter will lead to Firefox locking up while waiting on requests.

Finally, make sure that you take slow response times into consideration. In your testing you'll probably have very fast response times, but in production your database server and web server are likely to come under heavy load from time to time. The result of this is that the action of clicking a button, which previously gave instantaneous results via Ajax, might appear to have no affect at all. Make sure there is some sort of UI feed back to the user that your application is processing their action/request. Also slow response times, database time outs and other issues may lead to failed requests. Make sure you handle these or they may lock up your application.

Hope this helps...