title: Javascript Callback
body: <p>I have the functions below:</p>
  
  <p><em>(Normally I get the variable msg by doing some query on a XML Object)</em></p>
  
  <pre><code>function getMsg(callback) {
      var msg = "test"; 
      callback(msg);
  }
  
  function msgDone() {
      var message = null;
  
      getMsg(function(msg) {
         message = msg;
      });
  
      return message;  //Why is message undefined here?
  }
  </code></pre>
  
  <p>My problem is that I get an undefined on message. I have tested the function <code>getMsg()</code>, and it returns the right value.</p>
  
  <p>How will I make the msgDone to return the message that I get from callback? So that it doesn't return undefined?</p>
  
  <p>Thanks</p>