unable to get property 'childnodes' of undefined or null reference
-
function GetEqrDataUploadFiles()
{
var upload=$("#files").data("KendoUpload");
// in this line Error is coming " Unable to get property 'childNodes' of undefined or null reference "var s = upload.wrapper[0].childNodes[2].childNodes.length;
var a = new Array();
for (i = 0; i < s; i++)
{
if (document.all) {
a.push(upload.wrapper[0].childNodes[2].childNodes[i].innerText);
}
else {
a.push(upload.wrapper[0].childNodes[2].childNodes[i].textContent);
}
}
return a;
} -
function GetEqrDataUploadFiles()
{
var upload=$("#files").data("KendoUpload");
// in this line Error is coming " Unable to get property 'childNodes' of undefined or null reference "var s = upload.wrapper[0].childNodes[2].childNodes.length;
var a = new Array();
for (i = 0; i < s; i++)
{
if (document.all) {
a.push(upload.wrapper[0].childNodes[2].childNodes[i].innerText);
}
else {
a.push(upload.wrapper[0].childNodes[2].childNodes[i].textContent);
}
}
return a;
}If I'm not mistaken that looks more like Javascript. If so then I think you will get a better answer in this forum Javascript[^]
Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON
-
function GetEqrDataUploadFiles()
{
var upload=$("#files").data("KendoUpload");
// in this line Error is coming " Unable to get property 'childNodes' of undefined or null reference "var s = upload.wrapper[0].childNodes[2].childNodes.length;
var a = new Array();
for (i = 0; i < s; i++)
{
if (document.all) {
a.push(upload.wrapper[0].childNodes[2].childNodes[i].innerText);
}
else {
a.push(upload.wrapper[0].childNodes[2].childNodes[i].textContent);
}
}
return a;
}As the previous reply indicated -- this is Javascript -- and it is using -- most likely jQuery. I am responding because -- this snippet is accessing the DOM and making assumptions that are causing it to fail -- without grace and without any real way to provide much information, but -- the exception seems to indicate that the node being accessed is not present. This is not a good way to find the element in question and the code has been written in an odd manner because the author has not taken the time to understand nodes -- if you do not do this, your only options moving forward are to write code like this and hope for the best, or abdicate the responsibility by using a 3rd party client side library for that. To make matters worse, this issue of textContent vs. innerText -- is a well known difference between browsers and how they view whitespace in documents -- particularly XML documents. It behooves a developer to take the responsibility of learning how to walk the DOM themselves and to check for null -- at least once. How do you know where you are in the DOM otherwise? This script -- needs a lot of work to be robust --