有一个页面(url),我通过 XMLHttpRequest 请求它,但是我没有从请求的 url 中得到响应,它将请求定向到另一个页面,
请求--->page.php
得到回复 >定向页面.php
问题是如何获取响应 url? (示例中的directedpage.php)
The final URL (after following all redirects) is available in the responseURL attribute of a XMLHttpRequest
instance.
This feature is new and only supported in Firefox 32 stable in September 2014 [ref] and Chrome 37.0.2031.0 stable in August 2014 [ref] (and probably also Opera 24). responseURL
is not (yet) supported in IE 11 or Safari 7 and older browsers. For these browsers, the previous answer is still true:
XMLHttpRequest
自动遵循重定向,而不将所提供的 URL 保存在属性中。这Location
标头无法通过.getResponseHeader()
.
参考:
- https://groups.google.com/a/chromium.org/d/msg/blink-dev/AU6pAiYZ8J4/ec5jgoEDsF0J
- https://bugzilla.mozilla.org/show_bug.cgi?id=998076
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)