小试Ajax发现的几个小问题

来源:互联网 发布:房车工程数据 编辑:程序博客网 时间:2024/05/17 01:03

下面是能够正常运行的代码:    

    <script language="javascript" type="text/javascript">
    var XmlHttp=false;
    if(window.ActiveXObject){
        XmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest){
        XmlHttp=new XMLHttpRequest();
    }
   
    function sendAjax(){
     XmlHttp.open("POST","receive.aspx",true);
  XmlHttp.onreadystatechange=responsexml;
  XmlHttp.send('');
    }
   
    function responsexml(){
        if(XmlHttp.readyState==4||XmlHttp.readyState=="complete"){
            document.getElementById("info").value=XmlHttp.responseText;
        }
    }

</script>

 出现的问题:

1.411错误(firefox)原因是把XmlHttp.send('')写成了XmlHttp.send(null)  

2.同样在firefox XmlHttp.readyState写成了XmlHttp.readystate虽然在IE下能运行但在firefox就会出错,

看来firefox对大小写特别敏感!

原创粉丝点击