What is the difference between text and html data types when using jQuery ajax ()

Which makes jQuery different when you specify the data type as html, not text. I did not see the difference, but there should be some subtleties that I miss. If I want to return part of an html page as a string, does it matter what I use?

+5
source share
2 answers

"html": returns HTML as plain text; script tags are evaluated when pasted into the DOM. "text": A string of plain text.

And really, the only difference is that you have script tags.

source: http://api.jquery.com/jQuery.ajax/

+4
source

Using this html

<div id="foo">
  <span>hello world</span>
</div>

Differences

$("#foo").text(); //=> hello world
$("#foo").html(); //=> <span>hello world</span>
-2

All Articles