Hello,
I have made a function that updates the page after the ajax is ready... the function will insert images in a table. There error i get in firefox is:
Node was not found" code: "8
table.insertBefore(newRow,
tbodyKids[b]);
it works if i simply use table.appendChild(); but not if i use table.insertBefore().
here is my function: (Please see the comments near the bottom of the code)
function updatePage() {
if (request.readyState == 4) {
if (request.status == 200) {
var table = document.getElementById("a
cctable");
var tableKids = table.childNodes;
for (var a=0;a<tableKids.length;a++
) {
if (tableKids[a].nodeName == 'TBODY') {
var tbody = tableKids[a];
var tbodyKids = tbody.getElementsByTagName
("tr");
for (var b=0;b<tbodyKids.length;b++
) {
if(tbodyKids[b].className != "mheader") {
var rowCells = tbodyKids[b].getElementsBy
TagName("t
d")[1];
var text = rowCells.innerHTML;
// this regular expression will only return the numbers
var re = /[0-9]{3,6}/g;
// run the expression on our text string
var result = text.match(re);
// result.match(/(\d+)/);
var xmlDoc = request.responseXML;
var accomId = xmlDoc.getElementsByTagNam
e("TOUROPE
RATORCODE"
);
for (i=0;i<accomId.length;i++)
{
var theNode = accomId[i];
var theNumber = theNode.firstChild;
var numberVal = theNumber.nodeValue;
if (result == numberVal) {
var accomParent = accomId[i].parentNode;
var accomidKids = accomParent.childNodes;
for (d=0;d<accomidKids.length;
d++) {
if (accomidKids[d].nodeName == 'ACCOMTHUMB') {
var accomThumbKids = accomidKids[d].childNodes;
for (e=0;e<accomThumbKids.leng
th;e++) {
if (accomThumbKids[e].nodeNam
e == 'IMAGEURL') {
var accomthumbSrc = accomThumbKids[e].firstChi
ld;
var accomthumbSrcVal = accomthumbSrc.nodeValue;
var newRow = document.createElement("tr
");
table.appendChild(newRow);
// this works fine
table.insertBefore(newRow,
tbodyKids[b]); // this gives the error
var nextThumb = document.createElement("im
g");
nextThumb.setAttribute("sr
c", accomthumbSrcVal);
newRow.appendChild(nextThu
mb);
}
}
}
}
}
}
}
}
}
}
} else alert("Error! Request status is " + request.status);
}
}
Thanks
Steggs
Start Free Trial