i'm having a bug on firefox 3.6 using this function
function GetRefreshedResults(response)
{
var splitted = response.value.split("|");
var panel = document.getElementById('my-glider');
var anchors = panel.getElementsByTagName('a');
for (var i=0; i<anchors.length; i++)
{
anchors[i].innerHTML=splitted[i];
}
}
which ads in DOM anchors like "< a xmlns="http://www.w3.org/1999/xhtml">
I'm now trying to use this instead:
function GetRefreshedResults(response)
{
var splitted = response.value.split("|");
var panel = document.getElementById('my-glider');
var anchors = panel.getElementsByTagName('a');
for (var i=0; i<anchors.length; i++)
{
anchors[i].empty();
anchors[i].appendChild(splitted[i]);
// anchors[i].innerHTML=splitted[i];
}
}
but i get the following error in appendChild :
Uncaught Error: NOT_FOUND_ERR: DOM Exception 8
i don't understand why it's not working. can anyone help me ? thanks
EDIT: Example:
splitted[0] contains :
"<div class="var">Visits</div><div class="percent-zero">0%</div><div class="val">0<div class="val-alt">Unique Visits: 0</div></div>"
i want to update 8 anchors with new content, contained in splitted[0], splitted[1]...splitted[7]
splitted[i]
is the problem. appendChild
appends a DOM-element to an existing DOM-element, but it looks like you ar trying to append a string value. If you want to use appendChild
, either create a container element and use innerHTML
for that to insert the string, or just use innerHTML
. It is not a bug that you can't append a string as DOM-element, I'd say. See also the MDN-page on appendChild.
response.value.split("|");
Indicates to me that you are passing response
as a string. appendChild only works with elements. You can't append a child to a flat string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With