Return either local variable or GET results
<p>I would like to return x || $.get.</p>

<p>Or in other words, if x is true, then return x, else perform a GET call and return the value provided by the server.</p>

<p>My attempt is listed below (ideally, it would follow the return x || y format maybe with an anonymous function? instead of the if/then).</p>

<p>Problem is my return from my $.get function appears not to be what I expected.</p>

<p>Would appreciate an explanation of what is going on.</p>

<p>Thanks</p>

<pre><code>$(function(){

  function test(x,y) {
    if(x==true) {return true;}
    else{
      //test.php is echo($_GET['y']==123);
      $.get('ajax.php',{'y':y},function (status) {return status;});
    }
  }

  alert(test(false,123));

});
</code></pre>
