Javascript 引导对话框。模式(';隐藏';)不';隐藏模态?

Javascript 引导对话框。模式(';隐藏';)不';隐藏模态?,javascript,php,jquery,ajax,bootbox,Javascript,Php,Jquery,Ajax,Bootbox,我对bootbox.js modals有问题。 正在执行并等待响应就绪状态更改为3,模型将显示 但在请求完成且就绪状态更改为4且readystate 4正在console.log中打印后,模型不会隐藏 var dialog = bootbox.dialog({ message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i> Please wait while we

我对bootbox.js modals有问题。 正在执行并等待响应就绪状态更改为3,模型将显示 但在请求完成且就绪状态更改为4且
readystate 4
正在console.log中打印后,模型不会隐藏

    var dialog = bootbox.dialog({
    message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i> Please wait while we do something...</p>',
    className: 'bounceInUp animated',
    closeButton: false,
    show: false
                                  });

// ready stat with jquery
var _orgAjax = jQuery.ajaxSettings.xhr;

jQuery.ajaxSettings.xhr = function () {
    var xhr = _orgAjax();
    xhr.onreadystatechange = function() {

      console.log(xhr.readyState);

      var state = xhr.readyState;


      if (state == 3 ) {

      dialog.modal('show');
      console.log('readystate 3 ');

      }else if (state == 4) {

        dialog.modal('hide');
        console.log('readystate 4 ');

      };




    }
   return xhr;
};
var dialog=bootbox.dialog({
消息:“

我们正在做某事,请稍候…

”, className:“弹跳动画”, closeButton:false, 节目:假 }); //使用jquery准备好stat了吗 var\u orgAjax=jQuery.ajaxSettings.xhr; jQuery.ajaxSettings.xhr=函数(){ var xhr=_orgAjax(); xhr.onreadystatechange=函数(){ console.log(xhr.readyState); var state=xhr.readyState; 如果(状态==3){ dialog.modal('show'); console.log('readystate 3'); }else if(state==4){ dialog.modal('hide'); console.log('readystate 4'); }; } 返回xhr; };
您可以在ajax请求中使用它,方法是在发送之前使用选项
,并在ajax完成时始终关闭它

$.ajax({
  beforeSend: function() {
    dialog.modal('show'); <------------------ HERE show before
  },
  method: "POST",
  url: "some.php",
  data: { name: "John", location: "Boston" }
})
.done(function( msg ) {
    alert( "Data Saved: " + msg );
})
.always(function( msg ) {
    dialog.modal('show'); <----------------- HERE hide always on finish
 });
$.ajax({
beforeSend:function(){

dialog.modal('show');如果您使用jquery,为什么不使用$.ajax?我在这个代码后面使用它来帮助您,但是在尝试代码之后,我得到了这个错误->语法错误:预期表达式,得到了'。-->this.before.alwaysfunction@TarekRamadanah ty冗余;完成后。更新。