日期:2014-05-16  浏览次数:20591 次

关于ajax状态<4的问题 - Web 开发 / Ajax
HTML code
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
        //ajax xhttp
        var xmlHttp = false;
        try {
          xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
          try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (e2) {
            xmlHttp = false;
          }
        }
        if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
          xmlHttp = new XMLHttpRequest();
        }

        function callServer() {
            var  Rid = 3;
            var Star_Time="2010-03-25";
            var End_Time="2010-03-30";
            
            var url ="getRoom_Price.asp?rid=" +escape(Rid)+"&DStar_Time="+escape(Star_Time)+"&DEnd_Time="+escape(End_Time);
            
            alert(url);
            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = buildTextArea;
            xmlHttp.send(null);  
            
            }
        
        function buildTextArea(){
            
            if(xmlHttp.readyState < 4)
            {    
                alert("状态小于4");
            }
            if(xmlHttp.readySate == 4)
            {//xmlHttp Star
                alert("状态=4");
                if(xmlHttp.status!=200)
                {
                    alert("状态不等于200");
                } 
                else
                {
                    alert("状态=4 <200");
                }
            
            }
            }
</script>
</head>
<body> 
<table width="500" border="0" cellspacing="0" cellpadding="0"  id="AAAA">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<input type="button" onClick="callServer()" value="Submit111"/>
</body>
</html>


我这个请求状态总是小于4折腾很久了 初步估计是url 字符太长,服务器拒绝接收,有什么好的方法解决吗?

------解决方案--------------------
结贴 --- if(xmlHttp.readySate == 4)
写错了晕死。浏览器居然不报错。