Using jQuery I'm trying to output Json data containing a big chunk of HTML. This results in the HTML is being printed out in plain text, because it puts quotations marks around it. I want it as formated HTML. How can I achieve this? It's Json data from the Reddit API.
My jQuery
$.getJSON('https://www.reddit.com/r/GlobalOffensive/.json', function(data) {
$.each(data.data.children.slice(0,5), function(key, val) {
longHTML += '<div class="post">'+val.data.selftext_html+'</div><hr>'
});
$(".reddit-content").html(longHTML);
});
Results in
<div class="post">"<!-- SC_OFF --><div class="md"><h3><a href="#fnatic-logo"></a> Fnatic 0-2 <a href="#vp-logo"> ... etc etc ... <hr/> </div><!-- SC_ON -->"</div>
'; }else{ longHTML += '
' } }); $(".reddit-content").html(longHTML); }); See this fiddle: http://jsfiddle.net/hexjrbcb/ – Gregg Duncan Sep 11 '15 at 23:42