DataType vs ContentType in jquery ajax

ajax, jquery

Solution

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.

Problem

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 ?

Original source

Related problems