Javascript 重定向到其他页面后,如何保持toast bulma
从标题本身。是的,在页面重定向后,如何保持bulma祝酒词的活力?目前,我用bulma的toast保存数据的代码运行良好。但我试图实现的是在重定向后保持吐司 以下是我保存数据的ajax代码:Javascript 重定向到其他页面后,如何保持toast bulma,javascript,ajax,laravel,bulma,Javascript,Ajax,Laravel,Bulma,从标题本身。是的,在页面重定向后,如何保持bulma祝酒词的活力?目前,我用bulma的toast保存数据的代码运行良好。但我试图实现的是在重定向后保持吐司 以下是我保存数据的ajax代码: $.ajax({ headers:{'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}, url: "{{ route('payNow')
$.ajax({
headers:{'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
url: "{{ route('payNow') }}",
method: "POST",
data:{payNow: "TRUE"},
dataType: "json",
success:function(data)
{
if(data.success.length > 0){
// getDtls();
window.location = "//mydomain/reseller/transaction_history";
bulmaToast.toast({ message: data.success[0],
dismissible: true,
duration: 3000,
pauseOnHover: true,
animate: { in: "fadeIn", out: "fadeOut" },
type: "is-success" });
}else{
bulmaToast.toast({ message: data.error[0],
dismissible: true,
duration: 3000,
pauseOnHover: true,
animate: { in: "fadeIn", out: "fadeOut" },
type: "is-danger" });
}
},
error: function(xhr, ajaxOptions, thrownError){
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
如您所见,我首先对窗口进行编码。在Bulmotast
之前的位置
,期望web首先重定向并显示toast
效果
toast显示成功,但由于重定向,toast的显示速度太快,因此无法正确显示toast,因为代码已开始转换到下一页。如果希望toast显示在下一页上,则需要在转换之前显示,或者在当前页上显示toast,并向window.location发出setTimeout回调