在AJAX调用中获取重定向的php页面名称


Get the redirected php page name in AJAX call

在下面的代码段中,如果请求的"profile.php"重定向到另一个页面,如"login.php",如何识别它。

x=new XMLHttpRequest();
x.open("GET","profile.php",true);
x.onreadystatechange=function(){
if(x.readyState==4&&x.status==200)
{
alert("Requested url(profile.php) is loaded");
document.getElementById('content').innerHTML=x.responseText;
}
}

我们通过responseText成员获取页面的内容,是否可以获取请求对象的url或文件名。

if(x.status>300 && x.status<400) alert(x.getResponseHeader("Location"));

有关状态的更多信息,意味着