tags:

views:

349

answers:

4

All,

I know this is stupid simple but...

I'm using jQuery. I'm getting an XML document like this

$.ajax({
   type: verb,
   url: url,
   dataType: datatype,
   success: callback
   })
}

In my call back I want to update a div named ID="UpdateMe" with the result so that it looks like nicely formated XML.

This is my psudeo code for displaying the result.

function update_me_with_response(data){
  //I make it here just fine with no problems.
  //The following line is totally not working any ideas?  
      $("#ajaxer_output").text(data.text.escapeHTML());
   }
A: 

try

$("#ajaxer_output").html(data.text.escapeHTML())

Mech Software
+2  A: 

The difference between .text() and .html() is that .text escapes any html being sent in. so you could just use .text().

I'm assuming that you are getting html/xml back as a response and want to display the html/xml (including all of the angle brackets and markup) on the page?

Jon Erickson
A: 

If you want to display XML with tags try this:

function update_me_with_response(data){
    $("#ajaxer_output").html(data.replace(/</g, '&lt;'));
}

to do that maybe it's better to use a code tag instead of a div

tanathos
A: 

Try

$("#ajaxer_output").text(data.xml);
eibrahim