Javascript function not returning result
<p>I have a function that is not returning a value the way I would like it to. What the function does is get information that is echoed from a PHP page (the PHP page has an SQL query) and return it. Here it the code:</p>

<pre><code>function getValues(var1,var2) {
  $.post("http://url/to/file.php", {var1:var1,var2:var2}, function(data) {
    values = data.split(',');
    return values[0];
  });
}
</code></pre>

<p>I know that the PHP file is working because if I were to write <code>alert(data);</code> or <code>alert(values);</code> I can see the values there. When I call the function, for example, <code>var result = getValues(5,6);</code> result is undefined. Maybe it is because they are not in a list or an array? Help appreciated, thanks.</p>
