可能吗?这个怎么做?点击按钮时,我打电话给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