JavaScript and client side scripting.
Moderator: General Moderators
bimo
Forum Contributor
Posts: 100 Joined: Fri Apr 16, 2004 11:18 pm
Location: MD
Post
by bimo » Sat Sep 23, 2006 12:13 pm
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
nickvd
DevNet Resident
Posts: 1027 Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:
Post
by nickvd » Sat Sep 23, 2006 2:17 pm
appendChild expects a dom object, not a string...
Code: Select all
//untested
var obj = createElement('div');
obj.innerHTML = 'text';
document.getElementById('searchResults').appendChild(obj);
bimo
Forum Contributor
Posts: 100 Joined: Fri Apr 16, 2004 11:18 pm
Location: MD
Post
by bimo » Sat Sep 23, 2006 3:04 pm
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.
bimo
Forum Contributor
Posts: 100 Joined: Fri Apr 16, 2004 11:18 pm
Location: MD
Post
by bimo » Sat Sep 23, 2006 4:00 pm
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);
}
aaronhall
DevNet Resident
Posts: 1040 Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:
Post
by aaronhall » Sat Sep 23, 2006 5:24 pm
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.
bimo
Forum Contributor
Posts: 100 Joined: Fri Apr 16, 2004 11:18 pm
Location: MD
Post
by bimo » Tue Sep 26, 2006 1:10 pm
Excellent, that worked. Thanks for the quote clarification.