Ajax's responseXML Error
One thing that I see being asked more and more is why am I getting an error when I try to read the responseXML property. Well the main reason is normally the developer forgot to add the Content Type to set the document to XML. Other reasons is that the server has a problem with XML (I think I have seen this with Apache mainly.) As a result I wrote an article over on my site showing the error and how to correct it using the DOMParser.
You can find the article here: http://www.pascarello.com/TestHTMLXMLfromServer.htm. The best solution is to set the Content Type and make sure the server is serving the dynamic XML documents correctly!
Eric Pascarello
Moderator of HTML/JavaScript at www.JavaRanch.com
Author of: JavaScript: Your Visual Blueprint for Dynamic Web Pages
Eric
I used a sniffer program to trace the HTTP communication between my AJAX script and the ASP.NET web service webserver. I found the webserver did respond
Content-Type: text/xml; charset=utf-8
in the header followed by the SOAP response message. Would the extra "; charset=utf-8" have prevented the parser to load it automatically? IE on XP with SP2 didn't have any problem loading the response message automatically. I found I need to use your suggested approach to load the returned XML code explicitly on Mozilla-based browsers, e.g. Netscape 7.x and FireFox 1.5, though.
Timothy C.