-1
:javascriptでさらにステートメントを実行する前にbootbox.prompt()の結果を待つ方法はありますか?私は、コードを次している
var bootboxresult;
bootbox.prompt('Please enter some data', function(result) {
if (result != null) {
bootboxresult = result;
}});
alert(bootboxresult);
if(bootboxresult === null)
{
return;
}
if(bootboxresult != null)
{
Some Code To Excecute
}
コードは、プロンプトボックスが表示されますが、常に「bootboxresult」変数の内容は、nullまたは未定義です。
さらに、bootbox.prompt()が "bootboxresult"変数に値を格納するのを待つ必要があります。
お知らせください。
可能な重複http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an -asynchronous-call) – CBroe
ありがとう@CBroe、それは私の同期と非同期呼び出しの概念を助け、クリアしました。 –