Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在javascript中执行进一步语句之前,如何等待bootbox.prompt()结果?_Javascript_Bootstrap Modal_Bootbox - Fatal编程技术网

在javascript中执行进一步语句之前,如何等待bootbox.prompt()结果?

在javascript中执行进一步语句之前,如何等待bootbox.prompt()结果?,javascript,bootstrap-modal,bootbox,Javascript,Bootstrap Modal,Bootbox,我有以下代码: 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 Excecu

我有以下代码:

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”变量中


请告知。

我认为您可以将所有代码写在引导箱的回调中。见下面的例子

        var popup_content = "<b>Are you sure?</b><br><br>Do you want to delete?";
        bootbox.confirm(popup_content, function(result) {
              if(result){
                  // Write all your code here.  

              }else{
                 // else part code goes here
              }

        });
var popup\u content=“确定吗?

要删除吗?”; 引导框。确认(弹出内容、功能(结果){ 如果(结果){ //在这里编写所有代码。 }否则{ //否则部分代码在这里 } });
Thank@CBroe的可能重复,它帮助并清除了我的同步和异步调用概念。