title: Google Map API v3 - Ajax (Javascript + Jquery) GET issue
body: <p>I am trying to make the map load markers - pulled in from an xml file. It currently does this perfectly. However I also want the map to reload new markers based upon the month passed through from a hyperlink. </p>
  
  <p>When the 'global_month' variable is changed via hyperlink the ajax request fires and the 'data_array' should be repopulated with the new data based upon the date passed to the 'if' statement later on. However it reuses the 'data_array' contents, and doesn't fill it with new data.</p>
  
  <p>I have tried resetting the 'global_month' via 'global_month = []' in the 'change_date_range' function, however - the array doesn't seem to be refilled. I have spent 3 hours trying to work out where I am going wrong, but cannot. Can anyone help? Also is there a more efficient way of doing this? </p>
  
  <p>Thank you very much for you time!</p>
  
  <p>/////////////////////////////////////////////</p>
  
  <pre><code>            &lt;!DOCTYPE html&gt;
              &lt;html lang="en"&gt;
              &lt;head&gt;
                  &lt;meta charset="utf-8"&gt;  
                  &lt;script src="jquery-1.7.1.min.js" type="text/javascript"&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&gt;
                      $(document).ready(function()
                      {
                          $.ajax({
                              type: "GET",
                              url: "driving_test_centers.xml",
                              dataType: "xml",
                              success: parseXml
                          });
                      }); 
                      var global_month = 6;
  
                      function refetch()
                      {
                          $.ajax({
                              type: "GET",
                              url: "driving_test_centers.xml",
                              dataType: "xml",
                              success: parseXml
                          });
                      };          
  
  
  
                  var data_array = [];
                  var empty_holder;
                  var empty_month;
                  var info_date;
                  var address1;
                  var address2;
                  var town;
                  var county;
                  var postcode;
                  var lat;
                  var lon;
                  var male_pass_percentage1;
                  var male_pass_percentage;
                  var female_pass_percentage1;
                  var female_pass_percentage;
                  var the_new_date;
                  var infowindow;
                  var xml_contents;
  
                  function parseXml(xml)
                  {
                      $(xml).find("test_center").each(function()    // look for all of the test centers
                      {
  
                          center_name = $(this).attr('name');
                          address1 = $(this).find('address1').text();
                          address2 = $(this).find('address2').text();
                          town = $(this).find('town').text();
                          county = $(this).find('county').text();
                          postcode = $(this).find('postcode').text();
                          lat = $(this).find('lat').text();
                          lon = $(this).find('lon').text();
  
                          $(this).find("date_info").each(function()
                          {
  
                              info_date = $(this).attr('date');
                              empty_month = $(this).find('month').text();
                              male_pass_percentage = $(this).find('male');
                              male_pass_percentage = male_pass_percentage.find('pass_percentage').text();
                              female_pass_percentage = $(this).find('female');
                              female_pass_percentage = female_pass_percentage.find('pass_percentage').text();
  
  
                              if(empty_month == global_month){
                                  data_array.push([lat,lon,center_name,info_date,male_pass_percentage,female_pass_percentage]);
                              }
                          });
  
  
                      });
  
                  }
  
  
                  function change_date_range(the_new_date){
                      global_month = the_new_date;
                      refetch();
                      init();
                  };  
  
  
  
  
                  &lt;/script&gt;
                  &lt;script&gt;
  
  
                  function init() {
  
  
                      var options = {  
                          zoom: 5,
                          center: new google.maps.LatLng(55.3781, -3.4360),  
                          mapTypeId: google.maps.MapTypeId.ROADMAP  
                      };
                      var places;
                      places = null;  
  
                      var map = new google.maps.Map(document.getElementById('map'), options);
                      var bounds = new google.maps.LatLngBounds();
  
                      var places = data_array;
                      var temp_location;
  
  
                      for (var i = 0; i &lt; places.length; i++) {
  
                          temp_location = new google.maps.LatLng(places[i][0], places[i][1])
  
                          // Adding the markers
                          var marker = new google.maps.Marker({
                              position: temp_location, 
                              map: map,
                              title: places[i][2]
                          });
  
                          // Wrapping the event listener inside an anonymous function 
                          // that we immediately invoke and passes the variable i to.
                          (function(i, marker) {
  
                              // Creating the event listener. It now has access to the values of
                              // i and marker as they were during its creation
                              google.maps.event.addListener(marker, 'click', function() {
  
                                  // Check to see if we already have an InfoWindow  
                                  if (!infowindow) {
                                      infowindow = new google.maps.InfoWindow();
                                  }
  
                                  // Setting the content of the InfoWindow
                                  infowindow.setContent(places[i][2] + "&lt;br /&gt;" + global_month + "&lt;br /&gt;" + places[i][3] + "&lt;br /&gt;&lt;br /&gt;Male: " + places[i][4] + "%&lt;br /&gt;Female: " + places[i][5] + "%");
  
                                  // Tying the InfoWindow to the marker 
                                  infowindow.open(map, marker);
  
                              });
  
                          })(i, marker);
  
                          // Extending the bounds object with each LatLng
                          bounds.extend(temp_location);
  
                      }
  
                      // Adjusting the map to new bounding box
                      map.fitBounds(bounds)
  
                  };
  
  
  
                  &lt;/script&gt;
              &lt;/head&gt;
              &lt;body onload="init()"&gt;
  
                      &lt;div id="map" style="width:800px;height:600px"&gt;&lt;/div&gt;
  
                      &lt;a href="javascript:change_date_range(7)"&gt;click&lt;/a&gt;
              &lt;/body&gt;
              &lt;/html&gt;
  </code></pre>
  
  <p>/////////////////////////////////////////////////////////////</p>
  
  <p>XML file (small part of):</p>
  
  <pre><code>http://tinypaste.com/198889bb
  </code></pre>