如何获得响应URL中XMLHtt prequest? [英] How to get response url in XMLHttpRequest?
问题描述
有一个网页(网址),我要求它通过XMLHtt prequest,但我没有收到来自请求的URL的响应,它的指导要求到另一页,
There is a page (url), I request it by XMLHttpRequest, but I'm not getting response from requested url, It's directing request to another page,
请求 - > page.php
从得到效应初探> directedpage.php
requesting --- > page.php
getting reponse from > directedpage.php
和问题是我怎么能得到回应网址是什么? (directedpage.php的例子)
and the question is how can I get response url? (directedpage.php in example)
推荐答案
最后的URL(以下所有重定向后),请在的 responseURL
属性一个 XMLHtt prequest
实例。
此功能是新的,只支持在Firefox 32在2014年9月 [参考] 和Chrome 稳定37.0.2031.0 稳定在2014年8月 [参考] (及大概也歌剧院24)。 responseURL
没有(还)支持IE 11和Safari 7及以上的浏览器。对于这些浏览器,在previous答案仍然是正确的:
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:
XMLHtt prequest
自动跟踪重定向,而不保存服务的URL中的属性。该位置
头既可以通过检索 .getResponseHeader()
。
XMLHttpRequest
automatically follows redirects, without saving the served URLs in a property. TheLocation
header can neither be retrieved through the.getResponseHeader()
.
参考文献:
- <一个href="https://groups.google.com/a/chromium.org/d/msg/blink-dev/AU6pAiYZ8J4/ec5jgoEDsF0J">https://groups.google.com/a/chromium.org/d/msg/blink-dev/AU6pAiYZ8J4/ec5jgoEDsF0J
- <一个href="https://bugzilla.mozilla.org/show_bug.cgi?id=998076">https://bugzilla.mozilla.org/show_bug.cgi?id=998076
- https://groups.google.com/a/chromium.org/d/msg/blink-dev/AU6pAiYZ8J4/ec5jgoEDsF0J
- https://bugzilla.mozilla.org/show_bug.cgi?id=998076
这篇关于如何获得响应URL中XMLHtt prequest?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!