建立XMLHttpRequest对象(2)

<HTML><HEAD><TITLE>Ajax test</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT src="Ajax test_files/utl.js"></SCRIPT>
<LINK rev=stylesheet media=all href="Ajax test_files/Ajax.css" type=text/css
rel=stylesheet>
<SCRIPT>
//------------ XMLHttpObj类 ----------------
function XMLHttpObject(url,Syne){
 var XMLHttp=null
 var o=this
 this.url=url
 this.Syne=Syne
 this.sendData = function()
  {
    if (window.XMLHttpRequest) {
       XMLHttp = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
       XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    with(XMLHttp){
     open("GET", this.url, this.Syne);
     onreadystatechange = o.CallBack;
     send(null);
    }
  }

this.CallBack=function()
  {
    if (XMLHttp.readyState == 4) {
        if (XMLHttp.status == 200) {
          o.debugXML("readyState:" + XMLHttp.readyState + "<br/>")
          o.debugXML("status :" + XMLHttp.status + "<br/>")
          o.debugXML(" <div>" + createXmlTree(XMLHttp.responseXML,0) + "</div>")
        }
    }

  }

 this.getText=function()
  {
   if (XMLHttp==null) {return "还没加载 XMLHttpRequest"}
   if (XMLHttp.readyState==4) {return XMLHttp.responseText}
   return XMLHttp.readyState
  }

 this.debugXML=function(log)
  {
   try{document.getElementById("XMLDebug").innerHTML+=log}
   catch(e){}
  }
}
var XMLDoc1=new XMLHttpObject("tree.xml",true)

</SCRIPT>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wfzxyj.html