title: How to get data out of JQuery getJSON callback
body: <p>I need to get the JSON object data out of the callback function so that I can process it later in page, not within the callback as I am now. It must be obvious to everyone else as I can't see anything written about it. Can anyone tell me how to do it?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;script type="text/javascript" src="/site_media/js/jstree/_lib/jquery.js"&gt;&lt;/script&gt;  
  &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      function initialize() {
          var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
          var myOptions = {
              zoom: 4,
              center: myLatlng,
              mapTypeId: google.maps.MapTypeId.ROADMAP,
          }
          map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
          return map;
      }
  
      function add_marker(map, lat, long) {
          var marker_image='/site_media/images/map_marker.png';
          var myLatlng = new google.maps.LatLng(lat,long);
          title='title';
          var marker = new google.maps.Marker({
              position: myLatlng, 
              map: map, 
              title:title,
              icon:marker_image
          }); 
          //map.panTo(myLatlng);
      }
  
      //window.onload=initialize();
      setTimeout('map=initialize();',2000);
  
      $.getJSON("/ajax/get", function(data) {
          $.each(data, function(i,val) {
              latitude = val.fields.latitude;
              longitude = val.fields.longitude;
               add_marker(map, latitude, longitude);
          });
      });
  &lt;/script&gt;
  &lt;div id="map_canvas" style="width: 500px; height: 300px"&gt;&lt;/div&gt;
  </code></pre>