title: How to pass in HTML latitude and longitude into google reverse geocode to generate JSON data?
body: <p>I'm trying to generate geolocation data (Readable address) based on HTML lat/long data. </p>
  
  <p>I'm not able to request for a JSON output from google maps api with the following. Nothing is returned in the console window. I'm mainly trying to pass the HTML lat/long params into ajax block. Is it a syntax error having just the "pos" within the url line? Any suggestion would be appreciated.</p>
  
  <pre><code>&lt;body&gt;
  &lt;div&gt;
    &lt;p&gt;Click the button to get your coordinates.&lt;/p&gt;
  
    &lt;button onclick="getLocation()"&gt;Show Location&lt;/button&gt;
  
    &lt;p id="demo"&gt;&lt;/p&gt;
  &lt;/div&gt;  
    &lt;script&gt;
    var x = document.getElementById("demo");
  
    function getLocation() {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(showPosition);
        } else { 
            x.innerHTML = "Geolocation is not supported by this browser.";
        }
    }
  
    function showPosition(position) {
        x.innerHTML = "Latitude: " + position.coords.latitude + 
        "&lt;br&gt;Longitude: " + position.coords.longitude;
    }
  &lt;/script&gt;
  // Try HTML5 geolocation.
  if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
          var pos = {
              lat: position.coords.latitude,
              lng: position.coords.longitude
          };
  
  &lt;div id="map"&gt;&lt;/div&gt;
          &lt;script&gt;
  
            var map, infoWindow;
  
            function initMap() {
              map = new google.maps.Map(document.getElementById('map'), {
                center: {lat: -34.397, lng: 150.644},
                zoom: 12
              });
              infoWindow = new google.maps.InfoWindow;
  
              // Try HTML5 geolocation.
              if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(function(position) {
                  var pos = {
                    lat: position.coords.latitude,
                    lng: position.coords.longitude
                  };
  
                  infoWindow.setPosition(pos);
  
                  infoWindow.setContent('Location found.');
  
                  infoWindow.open(map);
                  map.setCenter(pos);
  
                }, function() {
                  handleLocationError(true, infoWindow, map.getCenter());
                });
              } else {
                // Browser doesn't support Geolocation
                handleLocationError(false, infoWindow, map.getCenter());
              }
            }
  
            function handleLocationError(browserHasGeolocation, infoWindow, pos) {
              infoWindow.setPosition(pos);
              infoWindow.setContent(browserHasGeolocation ?
                                    'Error: The Geolocation service failed.' :
                                    'Error: Your browser doesn\'t support geolocation.');
              infoWindow.open(map);
            }
          &lt;/script&gt;    
  
  &lt;script src="https://maps.googleapis.com/maps/api/js?key=************&amp;callback=initMap"&gt;
  
          &lt;/script&gt;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;
  
          $.ajax({
  
            url: "https://maps.googleapis.com/maps/api/geocode/json?latlng="+pos+"&amp;key=*********",
            type: "GET",
            success: function (data) {
              console.log(data)
  
            }
  
          })
          &lt;/script&gt;
  </code></pre>
  
  <p></p>
  
  <p>Update****Added all codes within *****</p>