Get XmlHttpRequest object
Copy codeThe Code is as follows:
// 1
Function getXMLHttpRequest (){
Var xmlHttpReq;
Try {// Firefox, Opera 8.0 +, Safari
XmlHttpReq = new XMLHttpRequest ();
} Catch (e ){
Try {// Internet Explorer
XmlHttpReq = new ActiveXObject ("Msxml2.XMLHTTP ");
} Catch (e ){
Try {
XmlHttpReq = new ActiveXObject ("Microsoft. XMLHTTP ");
} Catch (e ){
}
}
}
Return xmlHttpReq;
}
// 2
Function getXMLHttpRequest (){
Var xmlHttpReq = null;
If (window. ActiveXObject) {// Internet Explorer
XmlHttpReq = new ActiveXObject ("MSXML2.XMLHTTP. 3.0 ");
} Else if (window. XMLHttpRequest ){
XmlHttpReq = new XMLHttpRequest ();
}
Return xmlHttpReq;
}
// 3
Function getXMLHttpRequest (){
Var xmlHttpReq = null;
If (window. XMLHttpRequest) {// Mozilla Firefox, Opera 8.0 +, Safari
XmlHttpReq = new XMLHttpRequest ();
} Else {
If (window. ActiveXObject) {// Internet Explorer
Try {
XmlHttpReq = new ActiveXObject ("Microsoft. XMLHTTP ");
} Catch (e ){
Try {// Internet Explorer
XmlHttpReq = new ActiveXObject ("Msxml2.XMLHTTP ");
} Catch (e ){
}
}
}
}
Return xmlHttpReq;
}