result out of jQuery.post()
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call-from-a-function">How to return the response from an AJAX call from a function?</a>  </p>
</blockquote>



<p>Im trying to get result out of a function in which a jQuery Post function, but I dont know how to handle the date which I get as the result of the post function.</p>

<pre><code>    function getBuddyFromMessageId(id){
        var u = "testName";
        var result = "";
        $.post("http://localhost/fisrtproject/api.php?action=getBuddyFromMessageId", {
               username:u,
               message:id
               }, function (data){
               result = data;
               //the result is a normal string
               });

        return result;
    }
</code></pre>
