专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Ajax

Chrome下XMLHttpRequest无法获得asp.net返回的xml数据

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
Chrome下XMLHttpRequest无法获得asp.net返回的xml数据 - Web 开发 / Ajax
asp.net 中有一段代码:
-----------------
C# code

Response.ContentEncoding = System.Text.Encoding.UTF8;
string xmls = "<?xml version="1.0" encoding="utf-8" ?>rn";
xmls += "<apps>rn";
xmls += "  <app>rn";
xmls += "    <zp_id>1</zu_id>rn";
xmls += "  </app>rn";
xmls += "</apps>rn";
Response.ContentType = "text/xml";
Response.Charset = "UTF-8";
Response.AddHeader("Content-Disposition", "attachment;filename="apps.xml"");        
Response.Write(xmls);
Response.Flush();
Response.End();



然后在js中用代码

JScript code

var xhr = new XMLHttpRequest();                            
xhr.open("GET", "apps.aspx", true);
xhr.send(null);
xhr.onreadystatechange = function(){
  if(xhr.readyState == 4)
  {
    xmlDoc_3 = xhr.responseXML.documentElement;  //到这里chrome中就会出"Cannot read property 'documentElement' of null的错误"
  }
};



请问什么地方做的不正确呢?如果将 apps.aspx 直接用 apps.xml 代替,chrome就不会出错

但在ie6 7 8 和firefox中确没有任何错误

------解决方案--------------------
Response.AddHeader("Content-Disposition", "attachment;filename="apps.xml"");
这行没用
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: