0
有沒有一種方法在Javascript中等待另一個函數的完成,它的回調,並基本上「暫停」當前函數的完成,直到那個時候?Javascript函數等待直到完成遞歸異步函數調用它
例子:
var doSomething = function(callback) {
doSomethingElseAsynchronously(doSomething);
/* Wait until doSomethingElseAsynchronously */
/* is finished and it's callback has completed */
return callback();
};
https://stackoverflow.com/questions/5000415 /調用函數之前的功能是完成 –
[前一個函數完成後調用函數]可能的重複(https://stackoverflow.com/questions/5000415/call-a-function-after -previous-function-is-complete) –
搜索「javascript異步等待」以獲得很多答案。 –