我有两个在Android中被调用的JavaScript函数。经过长时间的调试,我终于意识到问题出在第二个函数在第一个函数完成之前被调用了。我已经搜索了关于延迟等方面的示例,但它们都依赖于函数在另一个函数内部调用。
function FunctInit(someVarible){ //someVariable is sent from android, cannot call again from getResult
//init and fill screen
}
function getResult(){ //also getResult need to be called from android via button
//return some variables
}
我该如何强制getResult等待FuncInit?是否有一种通过JavaScript实现这种方式的方法?
FunctInit
是否执行某些异步操作,您也希望等待其完成? - Paul S.