Ajax中的async
(默认: true) 默认设置下,所有请求均为异步请求。如果需要发送同步请求,请将此选项设置为 false。
var temp;
$.ajax({
async: false,
type : "POST",
url : defaultPostData.url,
dataType : 'json',
success : function(data) {
temp=data;
}
});
alert(temp);
async的默认设置为true,所有请求均为异步请求。若要将其设置为false,则所有的请求均为同步请求,在没有返回值之前,alert(temp)是不会执行的。
注意,同步请求将锁住浏览器,用户其它操作必须等待请求完成才可以执行。
注意,同步请求将锁住浏览器,用户其它操作必须等待请求完成才可以执行。
http://www.bkjia.com/Javascript/476873.htmlwww.bkjia.comtruehttp://www.bkjia.com/Javascript/476873.htmlTechArticlevar temp; $.ajax({ async: false, type : POST, url : defaultPostData.url, dataType : json, success : function(data) { temp=data; } }); alert(temp); async的默认设置为true,所有...
复制代码代码如下:
var temp;
$.ajax({
async: false,
type : "POST",
url : defaultPostData.url,
dataType : 'json',
success : function(data) {
temp=data;
}
});
美洲杯冠军竞猜,alert(temp);
这个ajax请求则为同步请求,在没有返回值之前,alert(temp)是不会执行的。
本文由美洲杯冠军竞猜发布于计算机教程,转载请注明出处:Ajax中的async
关键词: