2

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

1
  • What is the document's doctype? Is inserted HTML valid? Commented Jun 23, 2010 at 20:21

1 Answer 1

2
  • 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);
Sign up to request clarification or add additional context in comments.

5 Comments

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
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
Please provide the large data/html.
@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.
yeah all browsers can handle that except IE , I don't know why they not start from ground developing this browser

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.