function aa() {
var defer = $.Deferred();
$.ajax({
url: "/Handler1.ashx",
type: "post",
success: function (data) {
defer.resolve(data);//这里的data数据会传到$.when(aa()).done(function(data) data里面
}
});
return defer.promise();
}
$(function () {
$("#btnTest").click(function () {
var returnAA = "";
$.when(aa()).done(function (data) {
//当aa()方法执行完毕后在执行这里面的回调函数
returnAA = data;
alert(returnAA);
});
});
});