更新时间:2023-01-23 18:29:38
使用回调。这样的事情应该基于你的示例代码。
Use callbacks. Something like this should work based on your sample code.
function someFunc() {
callAjaxfunc(function() {
console.log('Pass2');
});
}
function callAjaxfunc(callback) {
//All ajax calls called here
onAjaxSuccess: function() {
callback();
};
console.log('Pass1');
}
这将打印 Pass1
立即(假设ajax请求至少需要几微秒),然后在执行 onAjaxSuccess
时打印 Pass2
。
This will print Pass1
immediately (assuming ajax request takes atleast a few microseconds), then print Pass2
when the onAjaxSuccess
is executed.