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.

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

}
}
);

Type:

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

 

URL:

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

 

ContentType:

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

 

dataType:

DataType is what we are expecting response from server.

Ex: json, html, text etc.

 

 

Please provide your comments.

Happy coding. Smile

 

 

 

 

 

10 Comments

  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.

  3. My programmer is trying to persuade me to move to .net
    from PHP. I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using Movable-type on several websites for
    about a year and am anxious about switching to another platform.
    I have heard good things about blogengine.net. Is there a way I can import all my
    wordpress content into it? Any kind of help would be really
    appreciated!

Leave a Reply

Your email address will not be published.


*