[新手询问]如何在IE7.0中创建XMLHttpRequest对象?

重返IT路 2009-02-10 11:54:01
function getClient(){
var client = getClientFromOthers();
if(client == null){
client = getClientFromIE();
}
return client
}

function getClientFromOthers(){
var client = null;
try{
return new XMLHttpRequest();
}catch(e){
}
return client;
}

function getClientFromIE(){
var client = null;
try{
if(window.ActiveXObject){
client = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.ActiveXObject){
client = new ActiveXObject("Msxml2.XMLHTTP.4.0");
}
else if(window.ActiveXObject){
client = new ActiveXObject("Msxml2.XMLHTTP");
}
}catch(e){}
return client;
}


本人获得XMLHttpRequest对象是这么写的,但这个对象就是创建不起来
...全文
107 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧