Fleegix.org

MSXML versions and XMLHttpRequest

2007-04-04 08:32:00

I got an e-mail this past week with an interesting question from a guy who was reading my Ajax book:

why you do the check for 'Msxml2.XMLHTTP' instead of 'Msxml2.XMLHTTP.6.0' which is apparently the latest release from Microsoft that has numerous improvements?

Naturally, I had an incredibly well-throught-out rationale for it -- "because that's how I originally did it, and it works." I had seen examples in the wild of using different specific program IDs (i.e., versions of the MSXML library) to get an XMLHttpRequest object, but never gave it much thought since my own code manifestly was working without.

Sure, "does it actually work" is the acid test -- no one cares how superbly designed your API is if they can't use your frigging app. But still, it's good to have someone ask these kinds of questions, so after the initial "ummm ..." reaction, you can get yourself educated. Otherwise it's all just cargo cult programming.

His initial e-mail kicked off a bit of discussion, and in the back-and-forth, there were some interesting links unearthed.

The bottom line, according to this post the Microsoft XML Team's Weblog, is that you should try to use MSXML 6.0 if you can, and if it's not available, you should fall back to MSXML 3.0:

Use MSXML 6.0 - it is "in the box" on Vista and available for download on Win2k, XP, and 2003. It has the best security, performance, reliability, and W3C conformance

MSXML 3.0 is our preferred "fallback" -- It is installed on every OS from a fully patched Win2k SP4 installation on up, so it requires "zero-deployment" and is serviced regularly with the OS

You can read for yourself what they say about the other version numbers on the blog post, but they don't recommend using them.

Using no program ID at all (e.g., new ActiveXObject('Msxml2.XMLHTTP')) will give you version 3.0. (From the blog post: "The version-independent ProgID is always bound to MSXML 3.") That's why it's no real sweat to be invoking the XMLHttpRequest object with no progID -- you get MS's preferred fallback anyway, so it works just fine. You just don't get the most up-to-date kung fu.

I've updated the XHR library for Fleegix.js to take this new info into account. That change, and a bunch of bugfixes make this newest one version 0.3.1.

About

This is the blog for Matthew Eernisse. I currently work at Yammer as a developer, working mostly with JavaScript. All opinions expressed here are my own, not my employer's.

Related

Previous posts

All previous posts ยป

This blog is a GeddyJS application.