求教:AJAX读取xml,对象总是为空 - Web 开发 / Ajax
服务器端代码: <?php $row = mysql_fetch_array($result, MYSQL_ASSOC); header("Content-Type: text/xml"); ?> <?xml version="1.0" encoding="gb2312"> <paikeresult> <classno-value><? echo trim($row['classno']); ?></classno-value> <cid-value><? echo trim($row['cid']); ?></cid-value> </paikeresult> 回调函数中的部分代码: var xmlDoc = request.responseXML; var xmlClassno = xmlDoc.getElementsByTagName("classno-value")[0]; var classno = xmlClassno.firstChild.nodeValue; 问题:xmlClassno(红色部分)这个对象总是空值null,求救,十分感谢
都试试,看哪个不为空了就用哪个: var xmlClassno = xmlDoc["classno-value"][0]; var xmlClassno = xmlDoc.document.getElementsByTagName("classno-value")[0]; 没用,都没用引用 var xmlDoc = request.responseText alert(xmlDoc ) 先看看返回了些什么内容,有没有你要的标签 谢谢你这个调试的方法,我也知道这样调试,可刚才有点乱没想到。 用这种方法,慢慢我就调过来了。 问题解决!十分感谢
相关问答:
我现在用struts2框架中需要使用ajax实现局部刷新,但是从容器里返回的值不知道怎么从struts.xml配置文件里映射到jsp页面里,以前servlet里写out.orint("xxxxx")就可以得到~,但是现在用struts就不知道怎么 ......
DataSet导出xml 批处理(循环)得怎么处理 XML文件 <A> <B> <C> </C> &nb ......
RT! xmlHttpRequest.send("提交参数名=值&提交参数名1=值"); var date={"数据1":"数据1值","数据2":"数据2值","数据3":"数据3值" ......
Private Sub Command1_Click() Dim MyString() As String Open "a.xml" For Binary As #1 ' 打开刚创建的文件。 ReDim MyString(LOF(1) - 1) Put #1, , MyRecord ' 读入所有字符到变量中 ......
思路:要用c#生成一个播放机的播放列表的xml,例如: <daty datys='2010-04-05' datye='2010-05-01' > //这是播放的日期段 <time times='01:12:00' timee='02:30:00'> ......