Search code examples
jqueryhtmlajaxjsonjsonp

sending html in JSONP request


I'm trying to make a request here https://s3.amazonaws.com/lawkickstas/lawkick_html.json for this...

{"html":"<div id=\'nates_widget\'>
  <div id=\'question\'></div>
  <form>
    <input type=\'text\' />
  </form>
  <div id=\'result\'></div>
  <div id=\'hints\'></div>
</div>"}

with this

$.getJSON("https://s3.amazonaws.com/lawkickstas/lawkick_html.json?callback=?",   function(result){
 //response data are now in the result variable
 alert(result);
});

but i'm getting an error unexpected token :
I'm wondering A. if this is the way to go about retrieving html from an external source and B. What is this callback and where do I put it?


Solution

  • @natecraft, you could also use $.getJSON

    $.getJSON("https://s3.amazonaws.com/lawkickstas/lawkick_html.json?callback=?",function(result){
    });
    function myJsonMethod(str) { console.log(str); }