mightykan

function getXMLDocument(){
  
var xDoc=null;
  
if (document.implementation 
    
&& document.implementation.createDocument)
    xDoc
=document.implementation
     .createDocument(
"","",null);    //Mozilla/Safari
  }
else if (typeof ActiveXObject != "undefined"){
    
var msXmlAx==null;
    
try{
      msXmlAx
=new ActiveXObject
       (
"Msxml2.DOMDocument");    //Newer Internet Explorer
    }
catch (e){
      msXmlAx
=new ActiveXObject
       (
"Msxml.DOMDocument");    //Older Internet Explorer
    
    }

    xDoc
=msXmlAx;
  }

  
if (xDoc==null || typeof xDoc.load=="undefined"){
    xDoc
=null;
  }

  
return xDoc;
}

function getXMLHTTPRequest() {
  
var xRequest=null;
  
if (window.XMLHttpRequest) {                        
    xRequest
=new XMLHttpRequest();    //Mozilla/Safari
  }
else if (typeof ActiveXObject != "undefined"){     
    xRequest
=new ActiveXObject
     (
"Microsoft.XMLHTTP");    //Internet Explorer
  }

  
return xRequest;
}

function sendRequest(url,params,HttpMethod){
  
if (!HttpMethod){
    HttpMethod
="POST";
  }

  
var req=getXMLHTTPRequest();
  
if (req){
    req.open(HttpMethod,url,
true);
    req.setRequestHeader
         (
"Content-Type"
          
"application/x-www-form-urlencoded");
    req.send(params);
  }

}

分类:

技术点:

相关文章: