Reputation: 5870
What does jQuery do differently when you specify the datatype as html as opposed to text. I haven't seen a difference but there must be some subtleties I'm missing. If I wish to return a portion of an html page as a string does it matter which I use?
Upvotes: 5
Views: 2075
Reputation: 77826
<div id="foo">
<span>hello world</span>
</div>
$("#foo").text(); //=> hello world
$("#foo").html(); //=> <span>hello world</span>
Upvotes: -2
Reputation: 1389
"html": Returns HTML as plain text; included script tags are evaluated when inserted in the DOM. "text": A plain text string.
So really the only difference is if you have script tags.
source: http://api.jquery.com/jQuery.ajax/
Upvotes: 4