views:

703

answers:

3

Microsoft finally added the native XMLHttpRequest object in Internet Explorer 7, but I found out that it can be disabled in the Internet Options dialog. So what benefit is there using XMLHttpRequest() vs ActiveXObject("Microsoft.XMLHTTP")?

If it can be disabled, that means we have to keep our browser compatibility checks in forever, doesn't it? Would XMLHttpRequest() initialize quicker than ActiveXObject("Microsoft.XMLHTTP") or what? Why would Microsoft add it and make it optional?

+2  A: 

This is a guess, but I would assume they allow it to be disabled for the same reason they allow JavaScript to be disabled. Some people believe the risks (privacy, security, whatever) outweigh the benefit and thus want it disabled.

Mayo
I could understand this, if it were disabled along with ActiveXObject. But you can actually disable XMLHttpRequest and still use ActiveXObject("Microsoft.XMLHttpRequest").
Andy E
+1  A: 

A good article on this one

ActiveXObject in Ajax

rahul
Thanks, although someone needs to show the author of that article the meaning of the <p> tag :)
Andy E
+2  A: 

The ActiveXObject can also be disabled. Note that other browsers can disable this and other settings as well. This is not about browser compatibility, but about user preference. Users can allow / disallow cross-domain requests, can allow / disallow scripts, can allow Flash or not etc.

You'll always have to check whether your page still runs smooth (or falls back gracefully) when users have disabled certain browser's features that you need.

The good news is: it is enabled by default, most users will have it on.

Update: by default, scripting and external requests (i.e. document(), xsl:include with XSLT or external entities in XML) are not supported by XmlHttpRequest-retrieved objects and must be enabled explicitly. This is different from non-IE browsers, where external requests from XHR-loaded documents are allowed (or don't exist, like in Safari and Chrome).

Abel
`The good news is: it is enabled by default, most users will have it on.` - That's why I asked the question, I found out one of my users didn't have it switched on and it was causing the application to fail. I didn't even realize it could be disabled until then.
Andy E