title: Pushing to Javascript Array from Jquery JSON request
body: <p>Why does this code always return 0?</p>
  
  <pre><code>     var possibleMatches = new Array();
    $.getJSON('getInformation.php', function(data) {
     $.each(data, function(i){
      possibleMatches.push(data[i]);
     })
    });
    alert(possibleMatches.length);
  </code></pre>
  
  <p>Though I can move or add "alert(possibleMatches.length);" inside the $.each and it will output the correct number of elements.</p>
  
  <p>I'm just curious as to why it the values aren't going into the array as I expected. I'm sure its a local variable vs. global variable issue, just not sure why.</p>
  
  <p>Basically, what this is trying to do is fill the possibleMatches array with the data results.</p>
  
  <p>thanks!</p>