gpt4 book ai didi

php - 为什么 window.location 不重定向页面

转载 作者:行者123 更新时间:2023-11-29 17:15:59 24 4
gpt4 key购买 nike

我想在上传成功后返回我的表单上传页面。警报运行良好,但窗口位置未运行。

这是我的代码。感谢帮助

 if ($uploadKey)
{
?>
<script>
alert("Upload succesfull");
window.location ('= form_upload.php');
</script>

<?php
}
else{
?>
<script>
alert("Upload failed");
window.location('=form_upload.php');
</script>
<?php
}

最佳答案

你想看语法吗?应该是

window.location = "PATH_TO_REDIRECT";

此外,您使用的是 PHP,您应该使用 header() 而不是 window.location

if ($uploadKey) {
header('Location: URL_HERE');
exit;
}

关于php - 为什么 window.location 不重定向页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17761746/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com