我需要知道如何捕获以下xmlhttprequest
中的位置字段Redirect
To:.....mp4
with status: 302 Show explanation HTTP/1.1 302 Moved Temporarily
Redirection information has not been cached.
Server: Apache/2.2.14 (Ubuntu)
Location:.....mp4
Content-Language: es-ES
Content-Type: text/html; charset=ISO-8859-1
Content-Length: 0
Expires: Wed, 31 Jul 2013 10:04:15 GMT
Date: Wed, 31 Jul 2013 10:02:13 GMT
Connection: keep-alive
Vary: Accept-Encoding
Status
200 OK Show explanation Loading time: 228
Request headers
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36
Content-Type: text/plain; charset=utf-8
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: es-ES,es;q=0.8
Cookie: odin=banebdyede;
__utma=.....;
__utmz=.....
Response headers
Cache-Control: max-age=2592000
Content-Length: 93692340
Content-Type: video/mp4
Expires: Fri, 30 Aug 2013 09:10:03 GMT
Last-Modified: Tue, 25 Jun 2013 15:31:25 GMT
Accept-Ranges: bytes
Server: Apache/2.2.14 (Ubuntu)
Date: Wed, 31 Jul 2013 10:02:13 GMT
Connection: keep-alive
我使用该代码:
var req = new XMLHttpRequest();
req.onreadystatechange = function (){
try{
if (req.status > 200){
alert ("status mayor q 200!!!");
}
alert ('status: ' + req.status + ' ready: ' + req.readyState);
if(req.readyState == 3 && req.status == 200){
alert (req.getResponseHeader('Location'));
alert (req.getAllResponseHeaders());
req.abort();
}
if(req.readyState == 4 && req.status >= 300){
alert ('entra!!');
alert ('status: ' + req.status + ' ready: ' + req.readyState);
alert (req.getResponseHeader('Location'));
alert (req.getAllResponseHeaders());
req.abort();
}
}catch (e){}
}
req.open('get', salida, true);
req.send();
但状态永远不会超过200且状态为200,无法访问标题“位置”
任何解决方案?
感谢和抱歉我的英语