返回重定向作为响应XHR请求 [英] Returning redirect as response to XHR request

查看:409
本文介绍了返回重定向作为响应XHR请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果浏览器接收重定向响应Ajax请求会发生什么?

What happens if the browser receives a redirect response to an ajax request?

推荐答案

如果浏览器收到重定向响应Ajax请求,会发生什么?

如果服务器发送重定向(又名302响应加一个位置:头)重定向是自动执行的浏览器。到的第二的请求的响应(假设它也不是另一个重定向)是什么,是暴露在你的程序。

If the server sends a redirect (aka a 302 response plus a Location: header) the redirect is automatically followed by the browser. The response to the second request (assuming it also isn't another redirect) is what is exposed to your program.

在实际上,不必以检测是否发生了302应答的能力。如果302重定向导致了200,那么你的程序的行为相同,如果原来的请求,直接导致了200。

In fact, you don't have the ability to detect whether a 302 response has occurred. If the 302 redirect leads to a 200, then your program acts identically as if the original request led directly to a 200.

这一直是我的两个经验和<一href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#infrastructure-for-the-send%28%29-method">behavior所谓在规范。

This has been both my experience and the behavior called out in the spec.

这篇关于返回重定向作为响应XHR请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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