aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes XmlHttpRequest.responseXML not populated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "XmlHttpRequest.responseXML not populated" Watch "XmlHttpRequest.responseXML not populated" New topic
Author

XmlHttpRequest.responseXML not populated

Scott Escue
Ranch Hand

Joined: Jan 20, 2005
Posts: 34
I'm attempting to use prototype to make an AJAX request to a server-side component that returns valid XML. Everything works as expected with one exception, the responseXML property of the XmlHttpRequest object is not being populated. The responseText property is populated with the text of the XML document, but I need the XML document object that should be available through responseXML. The problem is happening in IE 7. I've tried thiss with Firefox and it works fine, i.e. responseXML is populated. I'm not sure if there is a problem with the response I'm sending or if this is an IE issue. From all that I've read, responseXML should be populated automatically, even in IE, as long as the contenttype header in the response is set to "text/xml" and the XML itself is well-formed. If anyone has any insight or suggestions, I would greatly appreciate the help.

Here is the code from doGet method of the servlet that is sending the response:


The source for the HTML page that makes the request is below:


The xml that comes across is, not surprisingly,:



Thanks,
Scott
[ November 05, 2008: Message edited by: Scott Escue ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Shouldn't


be


Eric
Scott Escue
Ranch Hand

Joined: Jan 20, 2005
Posts: 34
Thanks, Eric. Indeed it should. It's correct in the original code; I messed it up when I created the simplified example. Unfortunately "request.responseXML.documentElement" returns null. I also checked the "responseXML.parseError" and got a value of 0, which should indicate there were no parsing errors.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Clear you cache in IE to make sure you do not have some old version in there.

Try doing step 4 here: http://radio.javaranch.com/pascarello/2006/09/12/1158096122600.html

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61662
    
  67

Looks like you're over-writing your content type.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Scott Escue
Ranch Hand

Joined: Jan 20, 2005
Posts: 34
Thanks, Bear, that was meant to be a call to setCharacterEncoding. Once I fixed that I noticed that the result of responseXML.documentElement went from null to an empty string (it's been an empty string all along in the original code). That prompted me to try outputing the nodeName of the document element for grins and much to my surprise, and embarrassment, it was "ajax-response".

So it seems my problem for the last day has simply been my own ignorance. I was expecting the output of responseXML.documentElement to be "[Object object]", or at least something other than an empty string. Thanks to you both, though, for helping me realize where I was going wrong.
[ November 05, 2008: Message edited by: Scott Escue ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: XmlHttpRequest.responseXML not populated