jQuery AJAX 抛出的 302 错误代码是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1473486/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the 302 error code that jQuery AJAX is throwing?
提问by AndreMiranda
I'm working with ASP.NET MVC and jQuery and I have a UserControl that is repeated on every page. In every page request, an AJAX callback occurs. So far so good.
我正在使用 ASP.NET MVC 和 jQuery,我有一个在每个页面上重复的 UserControl。在每个页面请求中,都会发生 AJAX 回调。到现在为止还挺好。
But when I'm in localhost and I publish the site, I notice that this AJAX is throwing a 302
error. This only occurs on https
pages, and only in FF and Chrome. On IE, the AJAX request works fine.
但是当我在 localhost 中发布站点时,我注意到这个 AJAX 抛出了一个302
错误。这仅发生在https
页面上,并且仅在 FF 和 Chrome 中发生。在 IE 上,AJAX 请求工作正常。
What is this 302 error? Why does it only occur on https
pages, and only in FF and Chrome?
这个 302 错误是什么?为什么它只出现在https
页面上,而且只出现在 FF 和 Chrome 中?
采纳答案by Chetan Sastry
HTTP 302 is used for redirection. My guess is that there is some sort of server error and you are being redirected to an error page using 302. Check the server logs for errors.
HTTP 302 用于重定向。我的猜测是存在某种服务器错误,您正在使用 302 重定向到错误页面。检查服务器日志是否有错误。
回答by DRaehal
See How to manage a redirect request after a jQuery Ajax callfor an in-depth discussion about the 302 issue.
有关302 问题的深入讨论,请参阅 如何在 jQuery Ajax 调用后管理重定向请求。
EDIT:
编辑:
Here are some other stackoverflow posts on the subject.
以下是有关该主题的其他一些 stackoverflow 帖子。
How to get jQuery.ajax response status?
Catching 302 FOUND in JavaScript
回答by Deniz Dogan
HTTP code 302 represents a redirection. The server is trying to tell you to redirect somewhere.
HTTP 代码 302 表示重定向。服务器试图告诉您重定向到某个地方。
回答by didxga
Does the server you accessing has Page Redirection facility? and that the page you access by Ajax was redirected to another page? If that is the case, you'd disable the redirection(at least ignore redirection for that page) then give it a try. PS: I think Ajax may not support url redirection.
您访问的服务器是否具有页面重定向功能?并且您通过 Ajax 访问的页面被重定向到另一个页面?如果是这种情况,您将禁用重定向(至少忽略该页面的重定向),然后尝试一下。PS:我认为 Ajax 可能不支持 url 重定向。