Rajesh Rs
Rajesh Rs

Reputation: 1391

How to display the contents of the xml document retrieved from the jquery.ajax()...?

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.. ??

Upvotes: 1

Views: 2277

Answers (2)

Artem Koshelev
Artem Koshelev

Reputation: 10604

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.

Upvotes: 2

Jayendra
Jayendra

Reputation: 52799

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)

Upvotes: 1

Related Questions