2

我在另一个 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

4

1 回答 1

3

你不能。 MethodeThatCallAjaxFunction可以通过同步(坏),也可以附加回调。

function mtcaf() {
    return $.ajax();
}
//snip
if (data == true) {
    mtcaf().done(function () {
        //some codes here
    });
}
于 2013-02-12T20:05:05.560 回答