52,797
社区成员
发帖
与我相关
我的任务
分享
var id;
dojo.xhrGet({
url: "http://localhost:8080/.....",
content:params,
preventCache: true,
handleAs: "text",
load: function(responseText)
{
id=responseText;
alert("function内:" + id);//这里会后弹出
},
error: function(response)
{
alert("Error");
}
});
alert("id is:" + id);//这里会先弹出
return id;
这就是异步请求的原理,异步请求不会等待当前请求执行完了才执行后台的代码的
改成同步的就好了