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

9 thoughts on “What is difference between contentType and dataType in jquery ajax method?”

  1. Hello there, just became aware of your blog through Google, and found that it is truly informative. I am going to watch out for brussels. I抣l appreciate if you continue this in future. Lots of people will be benefited from your writing. Cheers!

  2. Valuable information. Lucky me I found your site by accident, and I’m shocked why this accident did not happened earlier! I bookmarked it.

Leave a Comment

Your email address will not be published. Required fields are marked *

Share via
Copy link
Powered by Social Snap