evan
evan

Reputation: 31

IE doesnt add HTML to the dom using $.append or $.html()

I have a div that I'm trying to add html to. When I use a small html string it works, but when I try to add large html string nothing happens.

$("div") .html (data ) // about 1kB of html content 
$("div" ) .html() // it return empty 

If I do the same with a little html code like <p></p> it works. Any suggestions?

I am using Internet Explorer 8, it works just fine in other browsers

Upvotes: 2

Views: 183

Answers (1)

meder omuraliev
meder omuraliev

Reputation: 186762

  • How many divs are there?
  • Is data defined? If so what is it?
  • Does $('div').html('test') populate the divs?
  • Did you validate the huge block of html?
  • Did you escape the newlines?
  • Do any errors/exceptions get thrown? ( Firebug/Console )

If you get something like unterminated string literal then you just need to escape the newlines with \. You can also try making the variable and shorten it and see if jQuery fails at parsing it or not.

var longString = "\
<p>text</p>\
";

$('div').html(longString);

Upvotes: 2

Related Questions