1

I am invoking a web service through $.ajax(). onsuccess I am getting an xml document, now the problem is I need to see the contents of the retrieved xmlDocument..

Is there anyway to do that.. ??

4
  • where do you plan to show the documents? in a page? or do you just want to read it? you can print it out in console.log if you just want to read it manually Commented Sep 30, 2011 at 6:31
  • do you just want to see the result of the ajax call? Consider using Firefox with the Firebug add-on. It makes web development much easier. Commented Sep 30, 2011 at 6:31
  • can you show the sample xml you are receiving Commented Sep 30, 2011 at 6:47
  • @corroded: i just want to see the entire xml document returned. Commented Sep 30, 2011 at 7:00

2 Answers 2

2

Put it to the textarea field as-is

$("#textareaID").val(xmlstr); 

or display with html-encoding:

$("#someDivID").text(xmlstr); // jQuery text() function performs html-encoding automatically 

Simple demo: http://jsfiddle.net/wKhnF/1/

Note dataType: "text", it is required to process the response contents as a text rather then XML object.

Sign up to request clarification or add additional context in comments.

2 Comments

success: function(data,testStatus){ alert($.parseXML(data)); } here i am getting an alert showing [object:object]
change dataType to text as described, not xml
1

Use Firebug to check the response.

You can use http://api.jquery.com/jQuery.parseXML/ to read, parse the XML, find, and retrieve elements.

$.parseXML(xml) 

4 Comments

success: function(data,testStatus){ alert($.parseXML(data)); } here i am getting an alert showing [object:object]
thats an javascript object and you need to read through the elements you want to handle.
the problem is i dont know what kind of response the web service is sending.... i only know that it is an xml object ... so i want to know what is there inside the xmlDocument... is that possible .. ?????
Possible. Use firebug addon to check the response of your ajax requests on browser. It will display the xml. Or check for the solution mentioned by Artem.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.