PHP的标题():302临时移动错误 [英] PHP header(): 302 Moved Temporarily error

查看:184
本文介绍了PHP的标题():302临时移动错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的web应用程序我已经开了一个模式,并在该模式我处理与阿贾克斯在另一页(ajax.php)使用一些数据,之后的处理,在ajax.php我做的做的:

In my webapp I have opened a modal and in that modal I'm processing some data using with ajax in another page(ajax.php), after the processing is done in the ajax.php I do:

header("location: blah.php");

但自从我在另一个页面,整个过程与Ajax请求的页面没有做任何事情怎么回事,当我检查通过萤火Ajax请求,我看到了请求进入红色与此错误:

But since I'm in another page and the whole process is going on with ajax request the page doesn't do anything, when I check the ajax request via FireBug, I see the request goes red with this error:

302 Moved Temporarily error

我如何可以重定向在这种情况下?

How can I redirect in this scenario?

在此先感谢

推荐答案

响应已经重定向的 AJAX请求的。它不改变页面用户当前看到在浏览器中。这就是事情是这样的,你可以把它从PHP内不会改变。 AJAX请求是在后台完全执行,这是AJAX的地步。不管响应服务器返回不直接明显地影响在网站上这是目前对用户可见任何东西。你必须处理完全在Javascript的响应。

The response already redirects the AJAX request. It does not change the page the user is currently seeing in the browser. That's the way it is and you cannot change it from within PHP. The AJAX request was executed entirely in the background, that's the point of AJAX. Whatever response the server returns does not directly visibly affect anything on the site that's currently visible to the user. You have to handle the response entirely in Javascript.

如果您希望将用户重定向到基于失败的Ajax响应另一个页面,你就必须这样做在Javascript:

If you want to redirect the user to another page based on a failed AJAX response, you'll have to do so in Javascript:

$.ajax(..., function (data) {
    if (/* something or other */) {
        window.location = /* other page */;
    }
});

这篇关于PHP的标题():302临时移动错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆