为了账号安全,请及时绑定邮箱和手机立即绑定

window.location.href无法与sweetalert一起使用

window.location.href无法与sweetalert一起使用

PHP
冉冉说 2021-05-05 21:58:13
我正在使用html和php创建表单,提交表单后,我想用sweetalert显示成功消息,并希望将窗口定位到另一个页面。我尝试了以下代码,但没有用。请告诉我我要去哪里了echo '<script type="text/javascript">';echo 'setTimeout(function () {';echo 'swal("Success!","Your complaint has been successfully registered.\n Your Customer Complaint No. is\n  "+"'.$complainno.'","success")    .then( function(val) {  if (result.value) {        window.location = "/cashier.php";    }';             echo '});';echo '}, 200);  </script>';
查看完整描述

1 回答

?
慕尼黑8549860

TA贡献1818条经验 获得超11个赞

这是解决方案:


echo '<script>

        setTimeout(function() {

            swal({

                title: "Success!",

                text: "Your complaint has been successfully registered.Your Customer Complaint No. is"+$complainno,

                type: "success"

            }, function() {

                window.location.href = "cashier.php"; // window.location also can be used

            });

    }, 1000);

</script>';


查看完整回答
反对 回复 2021-05-28
  • 1 回答
  • 0 关注
  • 226 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信