无法读取null的属性'documentElement' [英] Cannot read property 'documentElement' of null

查看:122
本文介绍了无法读取null的属性'documentElement'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在使用此ajax.js从新闻网站中提取rss并注意到我收到此错误消息无法读取属性'documentElement'的null:ajax.js 149'可能是2-3次我认为当新闻网站将原始rss数据修改为某种方式(我猜测描述字段包括破折号等)时,它会给出该错误消息并且不显示内容..然后再次当他们更新了他们的xml时它再次工作......任何人都可以帮助我吗?



这是我在ajax.js中使用的代码的第149行



this.setXmlData = function(data){

this.xmlData = data;

this.rootName = data.documentElement.nodeName;



this.setMakeControl();

Hello I am using this ajax.js to pull rss from news websites and noticed that I am getting this error message that says "Cannot read property 'documentElement' of null: ajax.js 149' maybe like 2-3 times a week. I think when the original rss data is modified to certain way (I am guessing when the description field includes dashes or etc.) by the news website, then it gives that error message and doesn't display the content .. then again it works again when they have updated their xml... Can anyone please help me?

Here is the line 149 of the code that I use in ajax.js

this.setXmlData = function(data){
this.xmlData = data;
this.rootName = data.documentElement.nodeName;

this.setMakeControl();

推荐答案

你没有验证什么。

也许数据实际上是空的。



如果(data!== null)作为支票就是你需要的。

不要把rss提供给那里。
You're not validating anything.
Perhaps the data is actually null.

If(data!==null) as a check is what you need.
Dont asume the rss feed to be there.


这篇关于无法读取null的属性'documentElement'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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