| Author |
AJAX - responseXML is empty
|
Daniel Platon
Ranch Hand
Joined: Oct 10, 2005
Posts: 42
|
|
Hello everyone: I'm having some difficulties with AJAX. I am trying retrieve a list of elements (many elements ) via XMLHttpRequest. The request is posted to a Java Servlet which composes a XML file and sends it back. Although I specified the responseXML is empty. It worked fine with responseText and the content type set to "text/html". Here's my code as an example: Javascript in page: The code in the servlet is this: As I said before it worked fine with responseText Is there anything wrong here ?! Thanks a lot, Dan
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Are you running this on apache? (If yes, what version?) Eric
|
 |
Daniel Platon
Ranch Hand
Joined: Oct 10, 2005
Posts: 42
|
|
Sorry, I forgot to mention the environment. The whole thing runs in WSAD's embedded server. Thx, Dan
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
quick test to see if the headers are being set right on the server: See if that is saying text/xml or text/html in the list. Eric
|
 |
Daniel Platon
Ranch Hand
Joined: Oct 10, 2005
Posts: 42
|
|
Done that ! It says (and I quote ) The content-type looks ok. Thx, Dan
|
 |
kevin maloney
Greenhorn
Joined: Dec 19, 2005
Posts: 2
|
|
Can't say for sure whether this will help, but _sometimes_ the client-side routines for parsing responseXML barf silently if the content isn't correctly formed. There have been two approaches I've used to identify and solve this: 1) on the server, write out the complete contents that you're outputting (for example, using System.out.println) then copy that from your server output log to an XML validator. 2) on the client, pick up the results NOT as responseXML, but as responseText(), then issue a client-side alert() -- copy the contents of the alert box to an XML validator. Typically if I run into the problem you describe it's because of some unexpected flakiness in my data: for example, an ampersand or angle-bracket inside one of my data elements, or some other bizarre data anomaly. Hope this helps.
|
 |
 |
|
|
subject: AJAX - responseXML is empty
|
|
|