阮一峰的IT笔记:首页 -> 分类 -> Javascript 查看所有文章:按分类 | 按月份

在IE中建立XML HTTP请求对象

Like the XML DOM in IE, the XML HTTP request object has multiple versions, so a function is necessary to make sure you’re using the most recent one:

function createXMLHTTP() {

var arrSignatures = [“MSXML2.XMLHTTP.5.0”, “MSXML2.XMLHTTP.4.0”,
“MSXML2.XMLHTTP.3.0”, “MSXML2.XMLHTTP”,
“Microsoft.XMLHTTP”];
for (var i=0; i < arrSignatures.length; i++) {
try {
var oRequest = new ActiveXObject(arrSignatures[i]);
return oRequest;
} catch (oError) {
//ignore
}
}
throw new Error(“MSXML is not installed on your system.”);
}

« 用iframe与服务器通信 | 首页 | 建立通用的XML HTTP请求对象 »

About

This page contains a single entry from the blog posted on 2007年07月29日 14:23.

The previous post in this blog was 用iframe与服务器通信.

The next post in this blog is 建立通用的XML HTTP请求对象.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33

Post a comment