Javascript 如何在ASP MVC中提交警报后重定向到其他页面

Javascript 如何在ASP MVC中提交警报后重定向到其他页面,javascript,jquery,asp.net-mvc,sweetalert,Javascript,Jquery,Asp.net Mvc,Sweetalert,我正在开发一个ASP MVC 5 web应用程序 在我的一个页面中,我试图在发送邮件后将用户重定向到主页,这将在显示SweetAlert对话框后进行 事实上,该过程必须按以下顺序进行: 点击按钮确认 显示包含“确定”按钮的警报对话框 在此对话框中单击Ok 关闭警报对话框 将用户重定向到主页 问题是,为我工作的过程是以以下错误的方式进行的: 点击按钮确认 将用户重定向到主页 我的看法是: <input type="submit" value="Confirm" style="margin-l

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

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

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

  • 点击按钮确认
  • 显示包含“确定”按钮的警报对话框
  • 在此对话框中单击Ok
  • 关闭警报对话框
  • 将用户重定向到主页
  • 问题是,为我工作的过程是以以下错误的方式进行的:

  • 点击按钮确认
  • 将用户重定向到主页
  • 我的看法是:

    <input type="submit" value="Confirm" style="margin-left:-270px;" onclick="SendEmail()">
    
    
    
    
    var sendmail=函数(){
    jQuery.ajax({
    类型:“POST”,
    url:“/Bestellung/SendMailToUser”,
    成功:功能(数据){
    swal(“干得好!”,“您的订单已确认成功:),“成功”);
    window.location=“/Home/Index”;
    }
    })
    }
    
    您可以使用


    您希望该用户单击ok按钮并执行重定向

    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";
      }
    });
    

    swal(“干得好!”,“您的订单已成功确认:),“成功”)。然后(()=>{window.location=“/Home/Index”;})
    @Satpal它可以工作了!很多thx!!如果你对javascript和jquery有很好的了解,你能在这里看看我的问题吗:Thx
    swal("Good job!", "Your order has been confirmed with success :)", "success").then((value) => {
        window.location = "/Home/Index";
    });
    
    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";
      }
    });