为什么window.location没有';t重定向页面


Why window.location doesn't redirect the page

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

这是我的密码。感谢的帮助

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

您编写了错误的window.location语法。请写如下:

window.location = "form_upload.php";

代替:

 window.location ('= form_upload.php');