当前位置: 代码迷 >> ASP.NET >> 为什么xmlhttp读不到数据?解决方法
  详细解决方案

为什么xmlhttp读不到数据?解决方法

热度:3003   发布时间:2013-02-26 00:00:00.0
为什么xmlhttp读不到数据????
用Response.Write()
输出:

<?xml   version= "1.0 "   encoding= "GB2312 "   ?>  
<root>
<info> ok </info>
</root>


用xmlhttp获取

var   xmlDoc   =   xmlhttp.responseXML;//有object,非null
//var   root   =   xmlDoc.documentElement;  
var   node   =   xmlDoc.getElementsByTagName( 'info ');//有object,非null

var   str   =   node[0].firstChild.data;//这里却是null!!!!!!用node[0].firstChild.nodeValue;也不行。。。


alert(str);

------解决方案--------------------------------------------------------
xmlhttp.responseXML.是可以的.用操作xmldocument的方法来操作它.
------解决方案--------------------------------------------------------
就是查xmldocument的用户手册。。。。
不过你之前已经在用这种方式了。应该是属性用错了吧。
你用node[0].firstChild.text看看
------解决方案--------------------------------------------------------
node[0].InnerText;
------解决方案--------------------------------------------------------
var str = node[0].innerText
  相关解决方案