【发布时间】:2019-11-18 17:49:04
【问题描述】:
我对 bootbox.js 模式有疑问。
正在执行并等待响应就绪状态更改为 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;
};
【问题讨论】:
-
如果你使用 jquery 为什么你不使用 $.ajax ??
-
我在这段代码之后使用了它
标签: javascript php jquery ajax bootbox