Possible Duplicate:
Selecting HTML Comments with jQuery
Ajax functions like .load() strip out comments from the HTML. How can I keep the comments?
We are doing an AJAX call which is result is coming via
$('#page_section').html(result);
The problem is that the result is being stripped from all the HTML comments we have in there.
We need the HTML comments to stay there since they contain JSON objects which we need later by our CMS.
Any idea way to prevent HTML comments from being stripped with using .html().
Thanks!
document.getElementById("page_section").innerHTML = result;. I just read an answer on SO that says that .innerHTML() doesn't strip comments, bu I never tested it.data-attributes on HTML elements, allowing you to call the.data()method on any jQuery object to get and set values. That might be a cleaner, saner way to handle passing data with the HTML, rather than trying to put the JSON in comments and then parse it out. See http://api.jquery.com/jQuery.data/ and http://api.jquery.com/data/