Archive for August, 2011

IE8 doesn’t like my HTML

August 3, 2011

The problem

jQuery('div#space-for-' + institutionId).html(data);

This seemingly simple line of code was working fine in Chrome and FireFox, but did not result in placing the “data” HTML content in the selected div. Nothing at all changed on the page when in IE8.

I tested it in jQuery-1.4.2 and jQuery-1.6.2 with identical results.

The cure

Finally, I tried inserting a simple HTML string directly in the html() method:

jQuery('div#space-for-' + institutionId).html('<h1>Testing</h1>');

And it worked. Hmmm.

Mind your closing tags

After some careful parsing of my HTML, I discovered a missing </div> tag. That was causing IE8 to ignore the (fairly length) inserted fragment altogether. Add in the missing tag and…voilà…all is well again.