• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

AJAX - responseXML is empty

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you running this on apache? (If yes, what version?)

Eric
 
Daniel Platon
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Done that !

It says (and I quote )


The content-type looks ok.

Thx,
Dan
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic