IE8 doesn’t like my HTML

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: