这段代码的核心分为三步:
1.建立一个变量 xmlHttp 来引用即将创建的 XMLHttpRequest 对象。
2.尝试在 Microsoft 浏览器中创建该对象:
(1)尝试使用 Msxml2.XMLHTTP 对象创建它。
(2)如果失败,再尝试 Microsoft.XMLHTTP 对象。
3.如果仍然没有建立 xmlHttp,则以非 Microsoft 的方式创建该对象。
最后,xmlHttp 应该引用一个有效的 XMLHttpRequest 对象,无论运行什么样的浏览器。

/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
 xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
 try {
   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (e2) {
   xmlHttp = false;
 }
}
@end @*/
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
 xmlHttp = new XMLHttpRequest();
}

Written on 2007/03/09 by Doctor - Reads: 2089 Comments: 0

发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写