请问这个根据url得到xml数据对象的函数有问题吗?谢谢!!ie里得到对象为空,firefox可以!

5iasp
博客专家认证
2007-08-30 08:06:02
//根据url得到xmldata数据对象

function getXMLData(url,type)
{
var data="";
var xmlhttp = createXMLHttp();
try
{
xmlhttp.open("GET",url);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
if (type==0)
{
data=xmlhttp.responseText;
alert("data==="+data);
}
if (type==1)
{
//alert(xmlhttp.responseText);
data=xmlhttp.responseXML;
//data=xmlhttp.responseText;
alert("data==="+data);
}
}
}

xmlhttp.send(null);
}
catch(e)
{
alert("出现网络错误,请稍后再试!!!!!");
}
return data;
}
...全文
174 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
rob123 2007-08-31
  • 打赏
  • 举报
回复
有没有设置contenttype?
5iasp 2007-08-30
  • 打赏
  • 举报
回复
谢谢 createXMLHttp
这个函数这样的:

function createXMLHttp()
{
var ret = null;
try {
ret = new ActiveXObject('Msxml2.XMLHTTP');
}
catch (e) {
try {
ret = new ActiveXObject('Microsoft.XMLHTTP');
}
catch (ee) {
ret = null;
}
}
if (!ret && typeof XMLHttpRequest != 'undefined')
ret = new XMLHttpRequest();

return ret;
}
masse 2007-08-30
  • 打赏
  • 举报
回复
你的createXMLHttp函数怎么写的?

用个ajax框架多好啊
http://www.jopener.cn/category/ajax-frameworks/

52,797

社区成员

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

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