Javascript SweetAlert和重定向条件是否正常以及成功后消息

Javascript SweetAlert和重定向条件是否正常以及成功后消息,javascript,jquery,sweetalert,Javascript,Jquery,Sweetalert,我正在使用SweetAlert的版本1: 下面是我保存用户数据的示例ajax代码 $.ajax({ type: "POST", url: "test.php", data: {name1:name,status1:status}, cache: false, success: function(result){ $('#submit').prop('disabled', true); swal({ title: "Report Saved", type: "success", text: "T

我正在使用SweetAlert的版本1:

下面是我保存用户数据的示例ajax代码

$.ajax({
type: "POST",
url: "test.php",
data: {name1:name,status1:status},
cache: false,
success: function(result){
$('#submit').prop('disabled', true);
swal({
title: "Report Saved",
type: "success",
text: "The user details saved successfully!",
confirmButtonColor: "#00B4B4"
  });
},//success
error: function(result) 
{   
swal({
title: "Save failed",
type: "warning",
text: "We are unable to save data due to technical reasons!",
confirmButtonColor: "#00B4B4"
   });
 }  
});
如果status1 data==“Followup”,我需要重定向用户:

  • 显示成功消息后 及
  • 用户单击“确定”按钮后
  • 这怎么可能??我是一个新手,正在努力学习


    提前感谢

    您可以像这样将回调函数传递给
    swal对象

    swal({
         title: "Report Saved",
         type: "success",
         text: "The user details saved successfully!",
           confirmButtonColor: "#00B4B4"
      },function() {
        if(condition){
           window.location = "redirectURL";
        }
      });
    
    我使用Sweetalert 2 btw

    swal(
    title: "Save failed",
    type: "warning",
    text: "We are unable to save data due to technical reasons!",
    confirmButtonColor: "#00B4B4").then(() => { window.location = "redirectUrl" });
    

    单击“确定”按钮时,您将被重定向到特定的URL。将“redirectUrl”替换为所需的URL

    ,而此代码可能会回答问题,包括一些额外的细节和信息可以极大地提高其长期价值,帮助其他人理解它,因此可以获得更多的投票。考虑添加一些解释性文本
    swal(
    title: "Save failed",
    type: "warning",
    text: "We are unable to save data due to technical reasons!",
    confirmButtonColor: "#00B4B4").then(() => { window.location = "redirectUrl" });