Specifying the Data Type for AJAX Requests
From jQuery JavaScript Library
Jump to: navigation, search
The $.ajax function gives you the ability to specify a dataType parameter, which gives jQuery a hint as to what to expect in the response from the server. Based on this hint, jQuery processes the response data and passes it as the first argument to your success callback function (if provided). You may specify the dataType as a key/value pair in the lone argument passed to $.ajax. Supported types are:
* "xml": Treat the response as an XML document that can be processed via jQuery.
* "html": Treat the response as HTML (plain text); included script tags are evaluated.
* "script": Evaluates the response as JavaScript and evaluates it.
* "json": Evaluates the response as JSON and sends a JavaScript Object to the success callback.
Partager