重定向到另一个页面后如何保持吐司布尔玛
How do you keep toast bulma after redirecting to another page
来自标题本身。是的,你如何在页面重定向后保持 bulma 的敬酒?目前我用布尔玛吐司保存数据的代码工作正常。但我想要实现的是在重定向后保持祝酒词。
这是我的 ajax 保存数据的代码:
$.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);
}
});
如您所见,我在 bulmaToast
之前首先编写了 window.location
代码,以期望 Web 将首先重定向并显示 toast
效果。
toast显示成功,但是由于重定向导致toast显示速度过快
无法正常显示 toast,因为代码已经开始过渡到下一页。如果您希望 toast 显示在下一页,您需要在转换之前 flash the toast into the session,或者在当前页面上显示 toast,并使用 window.location.[=11= 的 setTimeout 回调]
来自标题本身。是的,你如何在页面重定向后保持 bulma 的敬酒?目前我用布尔玛吐司保存数据的代码工作正常。但我想要实现的是在重定向后保持祝酒词。
这是我的 ajax 保存数据的代码:
$.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);
}
});
如您所见,我在 bulmaToast
之前首先编写了 window.location
代码,以期望 Web 将首先重定向并显示 toast
效果。
toast显示成功,但是由于重定向导致toast显示速度过快
无法正常显示 toast,因为代码已经开始过渡到下一页。如果您希望 toast 显示在下一页,您需要在转换之前 flash the toast into the session,或者在当前页面上显示 toast,并使用 window.location.[=11= 的 setTimeout 回调]