我在另一个 AJAX 调用中进行了 AJAX 调用。
我正在使用$.ajax
方法:
$.ajax({
type: 'POST',
url: '/xx/xxx',
success: function (data) {
if(data == true){
var j = MethodThatCallAjaxFunction();
//some code here
}
}
});
如何确保在执行注释 //some code here
之后的代码之前填充 j
的值?
最佳答案
你不能。 MethodeThatCallAjaxFunction
可以通过同步(不好),也可以向其附加回调。
function mtcaf() {
return $.ajax();
}
//snip
if (data == true) {
mtcaf().done(function () {
//some codes here
});
}
关于jquery - AJAX同步完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14840782/