在满足特定条件之前,我们可以保持“ for”循环执行吗?我在for循环中有一个popup(Alert)。弹出询问用户确认(同意或取消选项)。但是循环不等待条件。基于弹出窗口“同意”或“取消”,我需要继续执行循环。
答案 0 :(得分:1)
您可以在这样的异步函数中执行内部确认弹出窗口-
select x.acc_num --into res
from xmltable (
xmlnamespaces (
default 'http://www.eubank.kz/Bis.Info.ExternalServices.Bank',
'http://schemas.xmlsoap.org/soap/envelope/' AS "s",
'http://www.w3.org/2001/XMLSchema-instance' as "i",
'http://schemas.microsoft.com/2003/10/Serialization/Arrays' as "a"
),
's:Envelope/s:Body/TryGetCardAccountsResponse/TryGetCardAccountsResult/IbanList/a:string'
passing xmltype(
'<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<TryGetCardAccountsResponse
xmlns="http://www.eubank.kz/Bis.Info.ExternalServices.Bank">
<TryGetCardAccountsResult
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<IbanList
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>KZ199480018A00166666</a:string>
<a:string>KZ519480061A02366666</a:string>
</IbanList>
<Status>Ok</Status>
</TryGetCardAccountsResult>
</TryGetCardAccountsResponse>
</s:Body>
</s:Envelope>'
)
columns
acc_num varchar2(255) path '.'
) x;
另一种替代方法是消除function asyncFunction(i) {
return new Promise(resolve => {
let response = confirm("Agree for iteration " + i);
resolve(response);
});
}
for (let i = 0; i < 5; i++) {
// Wait for the response of the asyncFunction to proceed to next iteration
asyncFunction(i).then((response)=>{
console.log(response);
// Further processing of the user's response
});
}
循环,并设置一个递归函数,像这样-
for
答案 1 :(得分:1)
您可以使用es6 aync / await概念
_dirname