可能嗎?這個怎麼做?點擊按鈕時,我打電話給function1
。如果條件爲真(i==1
),則function1
會暫停,並且僅在function2
完全執行後纔會執行以下代碼。例如:Javascript - 通話功能2內功能1,然後繼續
function1(i){
//some code here
if(i == 1){
function2(i); // call function2 and waits the return to continue
}
//the following code
}
function2(i){
//do something here and returns
}
讓你覺得JavaScript是不確定性... ??? – perilbrain
函數function2的調用是同步的:它等待函數2完成。你沒有什麼特別的事情要做。 –
可能過早地暴露於AJAX,並且破壞了他們對編程的感知。 – TheZ