What is difference between contentType and dataType in jquery ajax method?

AJAX: AJAX is Asynchronous JavaScript and XML. AJAX is a new technique to create faster and better web application.


jQuery AJAX Methods:

AJAX is used to send data to server, without refreshing whole page. It reloads part of page when data is exchange to server.

type: 'POST',
url: 'Default.aspx/GetData',
data: '{ }',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(msg) {



It is type of request GET/POST which will be sent to server.



It is URL where request will be send. Default is the current page.



The content type is type of data we are sending to server. Default is: “application/x-www-form-urlencoded,charset=UTF-8”



DataType is what we are expecting response from server.

Ex: json, html, text etc.



Please provide your comments.

Happy coding. Smile