(Default: true) By default, all requests are asynchronous. If you need to send synchronous requests, set this option to false. Note that a synchronous request will lock the browser, and the user must wait for the request to complete before other operations can be performed.
var temp;
$.ajax({
async: false,
type : "POST",
url : defaultPostData.url,
dataType : 'json',
success : function(data) {
temp=data;
}
});
alert(temp);
This ajax request is a synchronous request. Alert(temp) will not be executed until there is no return value. .
If async is set to: true, it will not wait for the result returned by the ajax request, but will directly execute the statement following the ajax.