我正在尝试使用 xml 和 javascript。在 Firefox 中使用 XMLHttpRequest 效果很好,但在 IE (6-8) 中我收到错误:
Object doesn't support this action
我正在使用以下功能:
function createRequestObject(){
var request;
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = false;
}
}
}
return request;
}
然后调用它:
var xhttp = createRequestObject();
xhttp.open("GET","myfile.xml",false);
...
有什么想法吗??