gpt4 book ai didi

javascript - 查询 : Wait for the toastr notification to end then reload

转载 作者:行者123 更新时间:2023-11-30 14:44:47 26 4
gpt4 key购买 nike

由于模态形式,我正在使用 ajax,我有一个 toastr 通知显示 ajax 成功。

toastr.success("我们会回复您,谢谢!");

然后:window.location.reload();

我怎样才能让它先结束通知然后重新加载。我找到了一些东西,但它很快就重新加载了页面:

$.when( toastr.success("We will get back to you with response, Thanks !") ).then(function( data, textStatus, jqXHR ) {
window.location.reload();
});

还有其他合适的/最佳实践方法吗?

最佳答案

伟大的toastr已经有隐藏动画结束的回调了:

toastr.options.timeOut = 1000;
toastr.options.fadeOut = 1000;
toastr.options.onHidden = function(){
// this will be executed after fadeout, i.e. 2secs after notification has been show
window.location.reload();
};

编辑:

您也可以只覆盖一个 toast :

toastr.success(
'Have fun!',
'Miracle Max Says',
{
timeOut: 1000,
fadeOut: 1000,
onHidden: function () {
window.location.reload();
}
}
);

关于javascript - 查询 : Wait for the toastr notification to end then reload,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49128052/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com