title: jquery callback not using global variable
body: <p>I have a small script that gets the location from geoplugin... i want to store the returned co-ords in a variable i have declared globally... but for some reason the callback wont read it. How do i make the callback use the global variable?</p>
  
  <pre><code>if(navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
          myLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
      }, function() {
          noLocation();
      },{timeout: 20});
  }
  else if (google.gears) {
      var geo = google.gears.factory.create('beta.geolocation');
      geo.getCurrentPosition(function(position) {
          myLocation = new google.maps.LatLng(position.latitude,position.longitude);
      }, function() {
          noLocation();
      });
  }
  else {
      noLocation();
  }
  function noLocation() {
  $.getJSON("http://www.geoplugin.net/json.gp?id=117.201.92.17&amp;jsoncallback=?",
      function(data) {
          if (data != "" &amp;&amp; data.geoplugin_latitude != "")
              myLocation =  new google.maps.LatLng(data.geoplugin_latitude, data.geoplugin_longitude)
          else
              myLocation = new google.maps.LatLng()
      });
  </code></pre>
  
  <p>}</p>
  
  <p>For some reason i think its because of the asynchronous call... Can i get over the issue some how?</p>