title: how can I return values from chained deferreds in jQuery?
body: <p>I'm trying to trace the return value from a function call:</p>
  
  <pre><code>$('#button').on('click', function(){
     console.log( getMessage(3) ); // I'm trying to get this to "hang" until ajax-related stuff is finished below
  });
  </code></pre>
  
  <p>The <code>ajaxFetch()</code> below is a generic ajax handler that returns the expected ajax deferred object. let's assume it's a string value: <code>'hello'</code>. Server response is several seconds.</p>
  
  <pre><code>function getMessage(id){
     ajaxFetch(id).done(function(result){
        // ... more stuff happening, but not relevant
     }).then(function(result){
        return (result); // I thought this would return to the click handler
     });
  }
  </code></pre>
  
  <p>How can I get my trace to output <code>'hello'</code>?</p>
  
  <h2>I think...</h2>
  
  <p>... that the <code>console.log()</code> needs to be somehow set up as a <code>promise</code> but I'm having a really hard time understanding the <a href="http://api.jquery.com/category/deferred-object/">jQuery documentation</a>.</p>