php 重定向标头未通过 ajax 调用发送
我正在尝试从使用 ajax 调用的 php 文件发送标头。问题是,当我使用 php 验证所有信息时,我想重定向到另一个页面,但标头不起作用!有什么想法吗?
代码的作用:
//------------- index.php
on click of input, function passes <input> values through $_POST to login.php
if($_SESSION[superman]==true){redirects to index_main.php}
//------------- login.php
all it does is validate forms and if login and password are correct, it sets $_SESSION [superman]=true
i am trying to send header from a php file that is called with ajax. problem is, when i validate all information with php, i want to redirect to another page but headers dont work! any ideas?
what the code does:
//------------- index.php
on click of input, function passes <input> values through $_POST to login.php
if($_SESSION[superman]==true){redirects to index_main.php}
//------------- login.php
all it does is validate forms and if login and password are correct, it sets $_SESSION [superman]=true
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
重定向只会重定向 Ajax 调用!如果您想更改浏览器中显示的页面,则需要在 Ajax 调用完成后使用 Javascript 进行重定向。
true
或可能是您要加载的页面的 URL)location.href
。The redirect will only redirect the Ajax call! If you want to change the displayed page in the browser, you'll need to redirect using Javascript once the Ajax call completes.
true
or maybe the URL to the page you want to load)location.href
using Javascript.