function createHttp()
{
//XmlHttpRequest并不是一个标准的产物,而是微软最初提出并得到很多浏览器支持的对象,因此其创建方法也是因浏览器而异的
//创建XmlHttpRequest对象
http_request=false;
if(window.XmlHttpRequest)
{
//非IE浏览器
http_request=new XmlHttpRequest();
}
else if(window.ActiveXObject)
{
//微软IE浏览器
try
{
//较新版本的IE浏览器
http_request=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
http_request=new ActiveXObject("Mircosoft.XMLHTTP");
}
catch(e)
{}
}
}
else
{
window.alert("你的浏览器版本已经严重过时,请升级后早做操作!");
return false;
}
}
function send_request()
{
createHttp();
http_request.open("GET","GetCity.aspx?ProvinceType="+document.getElementById('DropDownList1').value,true);
http_request.onreadystatechange=Getcity;
http_request.send(null);
}
function Getcity()
{
if(http_request.readyState==4)//请求完成,发送成功
{
//status属性表示HTTP请求的返回状态码,因为XMLHTTP也是请求的一个网页,所以它的含义和传统网页相同,如:200表示正常返回;404表示找不到网页;500表示服务器内部错误。
if(http_request.status==200)//交易成功
{
//在请求正常完成后,responseText表示以文本形式返回请求页面的内容
if(http_request.responseText!="")
{
//new Array(7),可以把7改成一个尽可能大的值,不如说选项中最大的值
var myarr=new Array(10000);
var ResponseText=http_request.responseText;
var pos=ResponseText.indexOf(";");
var i=0;
while(pos!=-1)
{
var myText=ResponseText.substring(0,pos);
if(myText!="")
{
myarr[i]=myText;
i++;
}
ResponseText=ResponseText.substr(pos+1);
pos=ResponseText.indexOf(";");
continue;
}
for(var n=0;n<i;n++)
document.getElementById("DropDownList2").options[n]=new Option(myarr[n],"");
document.getElementById("DropDownList2").length=i;
}
else
{
document.getElementById("DropDownList2").options[0]=new Option("请先选择省份","");
document.getElementById("DropDownList2").length=1;
}
}
}
红色代码为什么跳转不到指定页面