File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AJAX - responseXML is empty

 
Daniel Platon
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you running this on apache? (If yes, what version?)

Eric
 
Daniel Platon
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I forgot to mention the environment. The whole thing runs in WSAD's embedded server.

Thx,
Dan
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Done that !

It says (and I quote )


The content-type looks ok.

Thx,
Dan
 
kevin maloney
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic