使用 XMLHttpRequest 的创建方法
1 function createRequest()
2 {
3 /* Create a new XMLHttpRequest object to talk to the Web server */
4
5 var xmlHttp = false;
6 /*@cc_on @*/
7 if (@_jscript_version >= 5)
8 try {
9 xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
10 } catch (e) {
11 try {
12 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
13 } catch (e2) {
14 xmlHttp = false;
15 }
16 }
17 if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
18 xmlHttp = new XMLHttpRequest();
19 }
20
21
22 }
2 {
3 /* Create a new XMLHttpRequest object to talk to the Web server */
4
5 var xmlHttp = false;
6 /*@cc_on @*/
7 if (@_jscript_version >= 5)
8 try {
9 xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
10 } catch (e) {
11 try {
12 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
13 } catch (e2) {
14 xmlHttp = false;
15 }
16 }
17 if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
18 xmlHttp = new XMLHttpRequest();
19 }
20
21
22 }
注意,第六行的注释是不能删除的,不然代码无效!!!