我有以下代码无效。
$。当在.done
中的操作完成之前很久就立即返回。如何在.done
完成之前推迟采取行动?
var getReturn = function() {
$.post("/app/return.php", { auth: auth })
.done(function(data) {
// Does some calculations, does not return values
});
}
$.when(getReturn())
.done(function(response1) {
console.log('fire');
});
答案 0 :(得分:4)
您需要从$.post
getReturn()
返回的承诺
var getReturn = function() {
return $.post("/app/return.php", { auth: auth })
.done(function(data) {
// Does some calculations, does not return values
});
}