Source: Empty http://www.cnblogs.com/doll-net/archive/2007/03/13/673309.html
There are many ways to get XMLHTTP objects. The following are my actual usage and collected on the Internet;
In actual use, it is generally written in a class and put in a single file separately; a new object is used; errors are avoided when multiple objects are used at the same time.
1 Function XMLHTTP ()
2 {
3 VaR XMLHTTP = False ;
4 Try
5 {
6XMLHTTP= NewActivexobject ("Msxml2.xmlhttp");
7}
8 Catch (E)
9 {
10 Try
11 {
12XMLHTTP= NewActivexobject ("Microsoft. XMLHTTP");
13}
14 Catch (E2)
15 {
16XMLHTTP= False;
17}
18 }
19 If ( ! XMLHTTP && Typeof XMLHttpRequest ! = 'Undefined ')
20 {
21XMLHTTP= NewXMLHttpRequest ();
22}
23 Return XMLHTTP;
24 }
Function XMLHTTP () {
VaR XMLHTTP;
VaR Msxmlhttp = New Array (
'Msxml2. XMLHTTP. 5.0 ',
'Msxml2. XMLHTTP. 4.0 ',
'Msxml2. XMLHTTP. 3.0 ',
'Msxml2. xmlhttp ',
'Microsoft. xmlhttp ');
For ( VaR I = 0 ; I < Msxmlhttp. length; I ++ ) {
Try {
XMLHTTP= NewActivexobject (msxmlhttp [I]);
} Catch (E) {
XMLHTTP= Null;
}
}
If ( ! XMLHTTP && Typeof XMLHttpRequest ! = " Undefined " )
XMLHTTP = New XMLHttpRequest ();
Return XMLHTTP;
}