我有這樣的功能:運行代碼的JavaScript
function start_all(id) {
document.getElementById('status').innerHTML = "Starting...";
start(id); // This print too a status on the "status" div like: ID started
document.getElementById('status').innerHTML = "Done...";
}
我的問題是,最後一行是在函數開始(ID)之前運行;我需要在訂單上運行。
我的結果是:
Starting...
Done...
ID started
我需要這樣的:
Starting...
ID started
Done...
您需要使用承諾或回調。 – epascarello