原文出处:空空儿http://www.cnblogs.com/doll-net/archive/2007/03/13/673309.html
获取xmlHttp对象的方法很多;以下是我实际使用和网上收集的;
在我实际使用中一般写在一个类中并单独放在一个文件里;使用的时候new一个新对象;避免在同时使用多个时出现错误
1
function
xmlHTTP()
2
{
3
var xmlHttp = false;
4
try
5
{
6
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
7
}
8
catch (e)
9
{
10
try
11
{
12
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
13
}
14
catch (e2)
15
{
16
xmlHttp = false;
17
}
18
}
19
if (!xmlHttp && typeof XMLHttpRequest != 'undefined')
20
{
21
xmlHttp = new XMLHttpRequest();
22
}
23
return xmlHttp;
24
}

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24




















