title: Scoping issue with javascript callback
body: <p>I have a function that calls another function and I want to store the returned result in a variable:</p>
  
  <pre><code>function trigger_gridly(){
      var channel_name = get_channel_name();
  }
  </code></pre>
  
  <p>The called function triggers an AJAX request, which triggers a callback receiving JSON:</p>
  
  <pre><code>function get_channel_name(){
      var channel_name;     
      $.getJSON(APPLICATION_DOMAIN + "channels/new.json?callback=?", null, handleJson);
  }
  
  function handleJson(channel){
      var channel_name = channel.name;
      return channel_name;
  }
  </code></pre>
  
  <p>The problem is that the <code>channel_name</code> in <code>trigger_gridly()</code> does not receive the value of <code>channel_name</code> in the <code>handleJson</code> callback function. How can I expose the data in the callback to the <code>trigger_gridly()</code> function?</p>