Page 1 of 1
Could not convert JavaScript argument...
Posted: Sat Sep 23, 2006 12:13 pm
by bimo
I'm getting this error:
Exception... "Could not convert JavaScript argument arg 0 [nsIDOMHTMLDivElement.appendChild]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: ... :: handleResponse :: line 46" data: no
and this is the line that's causing it
Code: Select all
document.getElementById('searchResults').appendChild('searchImg');
Does anyone know what this error means? Is it that I'm passing a string rather than a document object?
Any help would be much appreciated,
b
Posted: Sat Sep 23, 2006 2:17 pm
by nickvd
appendChild expects a dom object, not a string...
Code: Select all
//untested
var obj = createElement('div');
obj.innerHTML = 'text';
document.getElementById('searchResults').appendChild(obj);
Posted: Sat Sep 23, 2006 3:04 pm
by bimo
Okay... I tried this
Code: Select all
if(http.readyState == 2 || http.readyState == 3){
var searchImg = document.createElement('img');
searchImg.setAttribute('src', "/design3/img/searching.gif");
searchImg.setAttribute('id', "searching");
document.getElementById(document.getElementById('searchResults')).appendChild('searchImg');
}
but it didn't work and I thought about using this.something but I'm not dealing with an object.
Sorry if this is a dumb question. I have looked for the answer but there are just so many resources (books, sites) and I can't find an answer that works.
What I'm really trying to do is get it to put the loading image div into the searchResults div.
Thanks,
b.
Posted: Sat Sep 23, 2006 4:00 pm
by bimo
tried this too:
Code: Select all
if(http.readyState == 2 || http.readyState == 3 ){
var searchImg = document.createElement('img');
var sRes = document.getElementById('searchResults');
searchImg.setAttribute('src', "/design3/img/searching.gif");
searchImg.setAttribute('id', "searching");
sRes.innerHTML = searchImg;
document.sRes.appendChild(searchImg);
}
Posted: Sat Sep 23, 2006 5:24 pm
by aaronhall
Try:
Code: Select all
if(http.readyState == 2 || http.readyState == 3){
searchImg = document.createElement('img');
searchImg.setAttribute('src', "/design3/img/searching.gif");
searchImg.setAttribute('id', "searching");
document.getElementById('searchResults').appendChild(searchImg);
}
In javascript, variable names must be outside of quotes to be interpreted as variables. Plus, you had some double getElementById thing going on. See if that code doesn't work.
Posted: Tue Sep 26, 2006 1:10 pm
by bimo
Excellent, that worked. Thanks for the quote clarification.