Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

swap the first two lines:

  $.getJSON(my_url, function(data) {
    $(document).ready(function(){
      $('<p>').text(data.some_text).appendTo('#some_container);
    });
  });


Very clever. This works because $(document).ready will execute immediately if the page is already loaded.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: