1

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());
   }

4 Answers 4

2

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?

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

Comments

0

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

Comments

0

Try

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

Comments

0

Try

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.