views:

38

answers:

1

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

+2  A: 
  • 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);
meder
it is one div , and the data is an htmltext got from html editor when I read it by watch I can see the data
evan
every thing wrok fine with little data but not with some thing bigger I think broken tags is the problem but why other browsers can handle it
evan
Please provide the large data/html.
meder
@evan, if it's broken HTML then the browser is under no obligation to do anything in particular with it. Different browsers definitely react differently to bad markup.
Pointy
yeah all browsers can handle that except IE , I don't know why they not start from ground developing this browser
evan