What is the significance of DataType and ContentType in jquery ajax ?
What is the purpose of both in client side request and Server side response ?
-
Is the content-type and data-type purpose differs between jQuery usage and REST API usage?sofs1– sofs12019-01-13 05:06:24 +00:00Commented Jan 13, 2019 at 5:06
Add a comment
|
2 Answers
dataType:
The type of data that you're expecting back from the server.
contentType:
When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding.
1 Comment
sofs1
Is the content-type and data-type purpose differs between jQuery usage and REST API usage?