How Web-Ready is XMLHttpRequest?
Monday, 23 January 2006
I’ve been playing around with some ideas that use XMLHttpRequest recently, but I keep on bumping up against implementation inconsistencies on IE vs. Safari vs. Opera vs. Mozilla. Although the interface exposed is pretty much the same, what it does in the background is very different, especially with regards to HTTP.
For example, some implementations will handle redirects and cache validation for you, while others will pass through the HTTP status codes, expecting you to pick up the pieces. This gets really annoying when you’re trying to use the Web to your advantage, rather that just make HTTP into another RPC protocol (which so many AJAX apps do… but I digress).
Frustrated by this and with a bit of spare time last week, I put together a set of tests for HTTP functionality in XMLHttpRequest (and friends). It’s fairly rough right now, but it’s already been useful to me. The fun part is it’s implemented on the server side with plain files and .htaccess magic (mostly mod_rewrite and mod_asis).
So far, the most bizarre thing I’ve come across is Safari’s inability to pop up an authentication dialog if you’re using XMLHttpRequest synchronously, even though it’s happy to do so if you’re working async. Basic redirect support is pretty universal, but things quickly fall apart on most browsers when you do tricky things like use non-GET/POST methods on redirecting resources. IE 6 is actually one of the better implementations I’ve tried so far (maybe not so surprising, considering they came up with it).
Anyway, give it a try; I need to work on the documentation and some of the tests, especially around caching. Ideally, I’d like to get some sort of result collection / summary thing going (and I’ve left a hook for it), but for now, it’s interesting to just look at (and maybe print) the per-browser results.
Feedback and suggestions appreciated below.
29 Comments
M. David Peterson said:
Tuesday, January 24 2006 at 2:03 AM
Joe Gregorio said:
Tuesday, January 24 2006 at 7:45 AM
Mark Nottingham said:
Tuesday, January 24 2006 at 8:18 AM
Mark Nottingham said:
Tuesday, January 24 2006 at 8:29 AM
Mark Nottingham said:
Tuesday, January 24 2006 at 8:34 AM
Joe Gregorio said:
Tuesday, January 24 2006 at 8:53 AM
M. David Peterson said:
Tuesday, January 24 2006 at 8:56 AM
Mark Nottingham said:
Tuesday, January 24 2006 at 9:46 AM
M. David Peterson said:
Tuesday, January 24 2006 at 10:34 AM
Julian Reschke said:
Tuesday, January 24 2006 at 11:47 AM
ingo said:
Tuesday, January 24 2006 at 12:08 PM
Stefan Eissing said:
Tuesday, January 24 2006 at 12:23 PM
Mark Nottingham said:
Wednesday, January 25 2006 at 5:15 AM
Yves said:
Thursday, January 26 2006 at 12:51 PM
Steven Williams said:
Thursday, February 9 2006 at 2:18 AM
Steven Williams said:
Thursday, February 9 2006 at 2:19 AM
Johan Sundström said:
Friday, February 10 2006 at 1:05 AM
Ben said:
Friday, February 10 2006 at 8:55 AM
Troels said:
Wednesday, March 22 2006 at 12:06 PM
good said:
Tuesday, April 25 2006 at 1:56 AM
Mark Nottingham said:
Tuesday, April 25 2006 at 3:36 AM
Yuri said:
Friday, July 7 2006 at 10:08 AM
Mark Nottingham said:
Friday, July 7 2006 at 11:15 AM
Marcus Granado said:
Monday, August 21 2006 at 5:54 AM
lemmett said:
Friday, October 20 2006 at 4:09 AM
Jon Hanna said:
Thursday, January 18 2007 at 8:35 AM
Jon Hanna said:
Tuesday, January 23 2007 at 8:07 AM
Jonathan Arkell said:
Sunday, June 24 2007 at 11:08 AM
ilango said:
Thursday, August 7 2008 at 11:34 AM