Click here to Skip to main content
15,867,765 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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();
Posted
Comments
Sergey Alexandrovich Kryukov 22-Oct-14 14:41pm    
What do you mean? Null doesn't have elements... :-)
What is null, data, or data.documentElement? It depends on what is data...
—SA
Sergey Alexandrovich Kryukov 22-Oct-14 16:15pm    
How about putting it in the question (using "Improve question")? Also, the sample needs to be comprehensive.
—SA

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900