title: wait for callback of getJSON finish in jquery
body: <p>I has something like this:</p>
  
  <pre><code>&lt;div id="content"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>and JS:</p>
  
  <pre><code>function getData(id) {
      $.getJSON('url/to/jsondata',{id: id}, function(data) {
           /** append some data to div#content  **/
           $('#content').data('key', 'value');
       });
  </code></pre>
  
  <p>then I want to get data of #content in script:</p>
  
  <pre><code>$(document).ready(function() {
      getData(1); // run getData with some id
      console.log($('#content').data('key'));
  });
  </code></pre>
  
  <p>Problem is console.log not run after callback of getJSON finish, so i get a undefined value in log.
  Which is right way to make it work?
  Thank!</p>