title: JavaScript variable not being set
body: <p>I have a small piece of js that pull some data from via ajax.</p>
  
  <pre><code>solarSystem = "test";
  
  $.getJSON( "ajax/getLocation.php", function( data ) {
        var items = [];
        $.each( data, function( key, val ) {          
              solarSystem = val;          
        });
  });
  
  alert(solarSystem);
  </code></pre>
  
  <p>val is being set but its not outputting to the alert if i put the alert in that function it works. I assume its something to do with scope but im new to js if anyone can point me in the right direction it would be much apreciated.</p>