0

在下面的代码段中,如果请求的“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或者文件名。

4

1 回答 1

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

更多关于状态含义

于 2012-08-31T09:50:35.137 回答