frequent
frequent

Reputation: 28503

Why does appending HTML via html() not work in IE8?

I'm debuggin a site on ie8 and cannot get dynamic content added via AJAX to display on the page.

The ajax call is done correctly, I can console.log/alert the returned HTML and there are no script errors popping up. Only a blank page with empty text node.

My script appending content looks like this:

// ajax content returned (HTML string)
var makeUp = data,
    target = $('.registryWrapper');

target.last()
    // css3 transition
    .addClass('fade out')
    // clear
    .html('')
    // add
    .html( makeUp )
    .append( someotherstuff )
    // Jquery Mobile enhancement
    .trigger('create')
    .removeClass('out')
    .addClass('in')

Any idea why this does not work in

Thanks!

Upvotes: 0

Views: 1157

Answers (1)

PhonicUK
PhonicUK

Reputation: 13864

In IE8, .html()/.innerHTML will do nothing if the HTML coming in isn't perfectly formatted (against the DTD being used) - it doesn't tolerate any mistakes unlike when it's parsing normally.

If you substitute data with something very simple like <p>Hello World!</p> then you should find it works (if that doesn't then something else is wrong) - in which case you need to find what is wrong with the HTML being passed in.

Upvotes: 2

Related Questions