IE加载xml的问题,小白求救

zerozml 2011-08-03 08:25:53
下面的代码在FF上没问题,但是在IE上却执行到open函数就不行了,求解啊~~~~~~~
function loadxml()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","pic_list.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
.................
.................
<body bgcolor="#999999" onload="loadxml();">
...全文
65 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
挨踢直男 2011-08-03
  • 打赏
  • 举报
回复
var ajax = {//xmlhttp request
tryList:function(){
var xhr = null;
for(var i=0;i<arguments.length;i++){
var lambda = arguments[i];
try{xhr = lambda();break;}catch(e){}
}
return xhr;
},
init:function(){
return this.tryList(
function(){return new ActiveXObject('MSXML2.XMLHttp.6.0');},
function(){return new ActiveXObject('MSXML2.XMLHttp.3.0');},
function(){return new XMLHttpRequest();},
function(){return new ActiveXObject('MSXML2.XMLHttp.5.0');},
function(){return new ActiveXObject('MSXML2.XMLHttp.4.0');},
function(){return new ActiveXObject('Msxml2.XMLHTTP');},
function(){return new ActiveXObject('MSXML.XMLHttp');},
function(){return new ActiveXObject('Microsoft.XMLHTTP');}
) || null;
}
}
var xmlhttp = ajax.init();
xmlhttp.open("GET","pic_list.xml",false);
xmlhttp.send(null);
xmlDoc=xmlhttp.responseXML;

87,990

社区成员

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

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