title: Google Maps API throws "Uncaught ReferenceError: google is not defined" only when using AJAX
body: <p>I have a page that uses the Google Maps API to display a map. When I load the page directly, the map appears. However, when I try to load the page using AJAX, I get the error: </p>
  
  <pre><code>Uncaught ReferenceError: google is not defined
  </code></pre>
  
  <p>Why is this?</p>
  
  <p>This is the page with the map:</p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"&gt;&lt;/script&gt;
  &lt;script&gt;
  var directionsDisplay;
  var directionsService = new google.maps.DirectionsService();
  var map;
  function initialize() {
    directionsDisplay = new google.maps.DirectionsRenderer();
    var chicago = new google.maps.LatLng(41.850033, -87.6500523);
    var mapOptions = { zoom:7, mapTypeId: google.maps.MapTypeId.ROADMAP, center: chicago }
    map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
    directionsDisplay.setMap(map);
  }
  $(document).ready(function(e) { initialize() });
  &lt;/script&gt;
  &lt;div id="map_canvas" style="height: 354px; width:713px;"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>And this the page with the AJAX call:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;script&gt;
  $(document).ready(function(e) {
      $('button').click(function(){
          $.ajax({
              type: 'GET', url: 'map-display',
              success: function(d) { $('#a').html(d); }
          })
      });
  });
  &lt;/script&gt;
  &lt;button&gt;Call&lt;/button&gt;
  &lt;div id="a"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks for your help.</p>