Internet Explorer AJAX Gotcha: “Object Required” Error

I came across this AJAX gotcha in IE yesterday … when I ran my brand new AJAX application in Internet Explorer 6.0 on my own computer, it worked fine, but when others ran it on their computers using the same version of IE, they got an “Object Required” javascript error.

I discovered (eventually) that, if the response to the XML HTTP request does not have Content-Type “text/xml”, then MSXML does not instantiate the responseXML member of the XMLHTTPRequest object, although it will instantiate the responseText member – see the MSXML2 API spec. Once I had fixed the server-side code to return the correct Content-Type, it worked. As an item of good-practice, you should probably include an “Accept: text/xml” header in the request, to be on the safe side.

Read the rest of this entry »