(via Ajaxian) IBM Developerworks has just published an Ajax Transport Method tutorial that describes a few of the alternatives to XMLHttp and provides example code to make them work.
For a more complete reference to all the available Ajax Transport layers, see my constantly evolving Ajax Transport Layer Alternatives presentation documentation. As someone who has actively used and promoted these techniques since 1998, I can say that I’m pretty familiar with the entire gamut of methods and their pros and cons.
The universal acceptance of the Ajax meme only became possible after more than 7 years of evolution and convergence of tools and techniques – CSS and DOM for presentation, XML and JSON for encoding, and various transport layers.
Much of the experimentation that took place during this time was centred around finding a way to transport data to and from the server in the background. Java applets, frames, layers, hidden iframes, image tags, script tags, XMLHttpRequest and Flash were all put to the test, each solving parts of the problem but mostly failing on compatibility, reliability or unwanted sideffects. XHR’s failure to take hold for the first 5 years of its existence was due to it being implemented as an ActiveX control only available in IE.
When Mozilla, Opera and Safari included the XMLHttpRequest object, it finally became the “good enough” solution upon which the Ajax juggernaut was launched.
While XMLHttpRequest has served to bring us to this stage in the game, it has some serious shortcomings that limit its long-term utility. As far back as 2002, Scott Andrew LePera pointed out an as-yet unfixed implementation problem, and more recently, Alex Bosworth enumerated a whole raft of issues. Harry Fuecks has spoken eloquently about network reliability and latency, the solutions to which would be best addressed with better control over timeouts, retries and error handling than XHR can provide.
As I’ve mentioned many times, Douglas Crockford’s JSONRequest proposal is one of the first real attempts to begin the discussions necessary to bring the changes about that will solve these issues. There was futher discussion at The Ajax Experience that included the major browser vendors, so I’m hoping that some from these beginnings, momentum will build.
Until there is a purpose-built Ajax transport built into browsers, advanced developers may want to learn all of the ins and outs of the different alternatives in order to choose the one that best fits the problem they are solving.