What is contenttype and datatype in Ajax request

$.ajax({
  type: "GET",
  url: "/api/employees/getemployee",
  data: {'id:'+Id},
datatype : "json",
contentType: " application/json",


success
: function(data){

$("#resultarea”).text(data);

},
error: function (){
}

In above sample request we have both content type and datatype . Content type means type of data you sending to service/method. Datatype means type of data you are getting back from service/method.

In above sample we are sending json data and getting Jason in response.

Leave a comment