gpt4 book ai didi

javascript - 如何在 ASP MVC 中提交警报后重定向到另一个页面

转载 作者:行者123 更新时间:2023-11-29 16:39:19 24 4
gpt4 key购买 nike

我正在开发一个 ASP MVC 5 Web 应用程序。

在我的一个页面中,我尝试在发送邮件后将用户重定向到主页,这将在显示 SweetAlert 对话框之后进行。

确实,该过程必须按以下顺序进行:

  1. Click on Button Confirm
  2. Showing alert dialog which contains Ok button
  3. Click on Ok in this dialog
  4. Close the alert dialog
  5. Redirecting the user to Home page

问题在于,我以以下错误的方式工作的过程:

  1. Click on Button Confirm
  2. Redirecting the user to Home page

这是我的观点:

<input type="submit" value="Confirm" style="margin-left:-270px;" onclick="SendEmail()">
<script>
var SendEmail = function () {

jQuery.ajax({
type: "POST",
url: "/Bestellung/SendMailToUser",


success: function (data) {

swal("Good job!", "Your order has been confirmed with success :)", "success");
window.location = "/Home/Index";
}

})
}

</script>

最佳答案

您希望用户单击“确定”按钮并执行重定向;

swal({
title: 'Good job!',
text: "Your order has been confirmed with success :)",
type: 'success',
showCloseButton:true
}).then((result) => {
if (result.dismiss === 'close') {
window.location = "/Home/Index";
}
});

关于javascript - 如何在 ASP MVC 中提交警报后重定向到另一个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48095989/

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