我正在使用html和php創(chuàng)建表單,提交表單后,我想用sweetalert顯示成功消息,并希望將窗口定位到另一個(gè)頁(yè)面。我嘗試了以下代碼,但沒(méi)有用。請(qǐng)告訴我我要去哪里了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貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超11個(gè)贊
這是解決方案:
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>';
- 1 回答
- 0 關(guān)注
- 235 瀏覽
添加回答
舉報(bào)
0/150
提交
取消