views:

2042

answers:

3

I'm having a problem where a jQuery setting against an .html() property on a selected element is returning the error 'nodeName' is null or not an object. This only occurs on IE6 and IE7, but not FF2, FF3, Opera (latest Nov 12,2008) or Safari (again, latest).

+2  A: 

I resolved the problem. The example looks like this:

$('#section #detail .data').html(data);

...where data is HTML returned from an AJAX call, and this bug only occurs on IE6 and IE7 on the second attempt AJAX call, not the first. It's inexplicable. The error returned is:

'nodeName' is null or not an object

The fix is to simply clear the variable first before setting:

$('#section #detail .data').html(''); $('#section #detail .data').html(data);

And then IE6 and IE7 started working again with it.

BTW, I had to install Visual Web Developer 2008 Express Edition to get a debugger working in IE7. That info is here.

there is no need to do a selector with two id's. Its slower than going direct to source
redsquare
A: 

I don't know if it's connected, but we've had what sounds like a similar issue where the DOM doesn't have the children/text of a element that we know exist (because we see them rendered on the screen!)

Selecting something else, then selecting the elememt again seemed to fix the issue - suddenly, the children appear. So what happens if you select you element, select something else, select your element again?

Paul
Thanks Paul. You caught me before I could post the answer. I had the question and the answer in my head already before posting, but it took me a second to post the answer. However, what you state is interesting because that's sort of what I'm doing.
A: 

Do you have any idea what kinds of nodes you might be running up against? Or, are you running in IE quirks mode? There might be some kinds of nodes such as #text that don't show up correctly in the DOM in quirks mode.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
Rob
I'm running XHTML Strict.