title: Get address coordinates of Google Maps API by ajax() request
body: <p>I'm trying to get lng and lat coordinates of the Google Maps API by the next example <a href="http://jsbin.com/inepo3/7/edit" rel="noreferrer">http://jsbin.com/inepo3/7/edit</a>. I expect a 'success' popup, but it keeps showing the 'Error' popup. 
  The google maps-request gives the correct json feedback (checked by firebug).</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $().ready(function() {
  
          $.fn.getCoordinates=function(address){
  
              $.ajax(
              {
                  type : "GET",
                  url: "http://maps.google.com/maps/api/geocode/json",
                  dataType: "jsonp",
                  data: {
                      address: address,
                      sensor: "true"
                  },
                  success: function(data) {
                      set = data;
                      alert(set);
                  },
                  error : function() {
                      alert("Error.");
                  }
              });
          };
  
          $().getCoordinates("Amsterdam, Netherlands");
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Does anyone know how to fix this issue?</p>
  
  <p>Regards,
  Guido Lemmens</p>
  
  <p>EDIT</p>
  
  <p>I found a bether solution using the Google Maps Javascript API combined in jQuery:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $().ready(function() {
          var user1Location = "Amsterdam, Netherlands";
          var geocoder = new google.maps.Geocoder();
          //convert location into longitude and latitude
          geocoder.geocode({
              address: user1Location
          }, function(locResult) {
              console.log(locResult);
              var lat1 = locResult[0].geometry.location.lat();
              var lng1 = locResult[0].geometry.location.lng();
              $("#testDiv").html("latitude:" + lat1 + "&lt;p&gt;longitude:" + lng1 + "&lt;/p&gt;");
          });
      });
  &lt;/script&gt;
  </code></pre>