簡體   English   中英

window.location.href無法使用sweetalert

[英]window.location.href not working with sweetalert

我正在使用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>';

這是解決方案:

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>';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM