title: Jquery return value from $.post() in function
body: <p>I've got a Javascript function called <code>getCartProducts()</code> which gets a JSON array via AJAX using <code>$.post()</code> which returns a value. I want to let my function return that value, but I don't know how to do that.</p>
  
  <p>Here's my function:</p>
  
  <pre><code>function getCartProduct(id){
    $.post('core/ajax/getCartProduct.ajax.php', {id: parseInt(id)}, function(data){
      var result = data;
    });
    return result;
  }
  </code></pre>
  
  <p>I know that this wont work, because te variable result is only active in the <code>$.post()</code> function, but I don't know how to get it straight.</p>