【发布时间】:2019-09-27 05:10:30
【问题描述】:
我正在使用下面的代码在 ajax 请求后显示通知
const Toast = Swal.mixin({ toast: true, position: 'top-end', showConfirmButton: false, timer: 3000 });
//ajax call
$.ajax({
.....
success: function(response){
reloadpanel1(response.id); //another ajax call
reloadpanel2(response.id); //another ajax call
Toast.fire({
type: 'success',
title: response.message,
customClass: { popup: 'adjust' }
})
}
})
问题是通知在reloadpanel1 和reloadpanel2 完成他们的请求之前弹出。
如果所有 ajax 调用尚未完成,有没有办法让 Toastr 不会触发?
编辑:
$(document).ajaxStart()/.ajaxStop() 不会这样做,因为通知消息取决于 json response.message 值
【问题讨论】:
标签: javascript ajax sweetalert sweetalert2