1
<p id="[email protected]">
  <script type="text/javascript">
    $(document).ready(function () { 
      GetSelfText('@item.ThreadID'); 
    });
  </script>
</p>

function GetSelfText(thingId) { 
  $.getJSON("http://www.reddit.com/r/playitforward/comments/" + thingId + "/.json?jsonp=?",
            { id: thingId }, 
            function (data) { 
              $("#selfText-" + thingId).html(data[0].data.children[0].data.selftext_html) 
            }) 
}

Right now it's encoding the html and wrapping the html in quotations. I need it to be raw html. I also am trying to use a JQuery Expander and it's not working for ajax inserted content.

So I need to solve 2 problems. Insert the returned data as raw html and make the expander plugin work with ajax inserted content.

1 Answer 1

1

The encoding happens from the reddit api.

Try

function (data) { 
    var tempHtml = $('<div/>').html( data[0].data.children[0].data.selftext_html ).text();
    $("#selfText-" + thingId).html( tempHtml ) ;
}

as the callback method..

Sign up to request clarification or add additional context in comments.

1 Comment

@sevenalive, glad it worked.. for the expander you might want to describe the issue in more detail, and post related code as well (perhaps a new question is better)

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.