• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

XmlHttpRequest.responseXML not populated

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shouldn't


be


Eric
 
Scott Escue
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like you're over-writing your content type.
 
Scott Escue
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Popeye has his spinach. I have this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic