求高手指点

  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;
                 }          
            }
        }

红色代码为什么跳转不到指定页面

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值