$.ajax(opts) makes an Ajax call using XMLHttpRequest Object.
Examples below
$.ajax({
type:"GET",
url:"mypage.php",
data:{'foo':'bar'},
success:function(data){}
});
Below is an example for posting a JSON payload to a server
$.ajax({
type:"post",
url:"/api/updateuser/",
data:{id:1,username:'bill'},
contentType:"application/json"
});
When the response has the type 'application/json', we will return the JSON object for you.
When the response has the type "application/xml", we return responseXML.
When the response has the type "text/html", we call $.parseJS on the result to process any JS scripts in the response.
Below is the code to show the dataType values
switch (settings.dataType) {
case "script":
settings.dataType = 'text/javascript, application/javascript';
break;
case "json":
settings.dataType = 'application/json';
break;
case "xml":
settings.dataType = 'application/xml, text/xml';
break;
case "html":
settings.dataType = 'text/html';
break;
case "text":
settings.dataType = 'text/plain';
break;
default:
settings.dataType = "text/html";
break;
case "jsonp":
return $.jsonP(opts);
}