Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between text and html datatypes when using jQuery's ajax()

Tags:

jquery

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?

like image 658
user169867 Avatar asked Nov 06 '22 14:11

user169867


1 Answers

"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/

like image 178
Samuel Avatar answered Nov 15 '22 12:11

Samuel