File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XmlHttpRequest.responseXML not populated

 
Scott Escue
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shouldn't


be


Eric
 
Scott Escue
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like you're over-writing your content type.
 
Scott Escue
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic