我在另一个AJAX调用中有一个AJAX调用。
我正在使用$.ajax
方法:
$.ajax({
type: 'POST',
url: '/xx/xxx',
success: function (data) {
if(data == true){
var j = MethodThatCallAjaxFunction();
//some code here
}
}
});
在评论j
之后执行代码之前,如何确保填充//some code here
的值?
答案 0 :(得分:3)
你做不到。 MethodeThatCallAjaxFunction
可以是同步(坏),也可以附加回调。
function mtcaf() {
return $.ajax();
}
//snip
if (data == true) {
mtcaf().done(function () {
//some codes here
});
}