在firefox,chrome中解析xml时,Javascript返回'undefined' [英] Javascript returns 'undefined' when parsing xml in firefox,chrome

查看:140
本文介绍了在firefox,chrome中解析xml时,Javascript返回'undefined'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Javascript在IE中工作正常,但在其他浏览器中没有,它显示未定义错误



我尝试过:



我的鳕鱼是:



var data = XmlHttp.responseXML.documentElement;

if(data.getElementsByTagName('Description')[0] .text ==&& data.getElementsByTagName('Course_Info')[0] .text!=)

{

textInfo = data.getElementsByTagName('Course_Info')[0] .lastChild.nodeValue;

document.getElementById('txtAreaShow')。value = textInfo;

}



我尝试了很多方法,但没有得到答案。有没有解决方案?

Javascript work correct in IE but not in other browsers,it showing 'undefined' error

What I have tried:

my cod is:

var data=XmlHttp.responseXML.documentElement;
if ( data.getElementsByTagName('Description')[0].text =="" && data.getElementsByTagName('Course_Info')[0].text !="")
{
textInfo=data.getElementsByTagName('Course_Info')[0].lastChild.nodeValue;
document.getElementById('txtAreaShow').value = textInfo;
}

I tried many ways,but not get the answer. Is there any solution?

推荐答案

在浏览器中使用开发者控制台。

你会看到问题的原因和原因。 />


您可能正在使用某个浏览器中存在的内容而其他浏览器中不存在。
Use the developer console in the browsers.
You will see why and where is the problem.

You are probably using something that exist in one browser and don't exist in others.


var data = XmlHttp.responseXML。 documentElement;

if(data.getElementsByTagName('Description')[0] .lastChild == null && data.getElementsByTagName('Course_Info')[0] .lastChild!= null)

{

textInfo = data.getElementsByTagName('Course_Info')[0] .lastChild.nodeValue;

document.getElementById('txtAreaShow')。value = textInfo;

}

谢谢大家:)最后我得到了自己的解决方案..干杯(Y)
var data=XmlHttp.responseXML.documentElement;
if ( data.getElementsByTagName('Description')[0].lastChild ==null && data.getElementsByTagName('Course_Info')[0].lastChild !=null)
{
textInfo=data.getElementsByTagName('Course_Info')[0].lastChild.nodeValue;
document.getElementById('txtAreaShow').value = textInfo;
}
Thank you everybody :) finally i got my own solution .. cheers (Y)


这篇关于在firefox,chrome中解析xml时,Javascript返回'undefined'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆