JSFiddle - React, Tailwind, and code Playground

by sarathsprakash

HTML

<body>
    <input type="text" id="hi" />
    <input type="button" id="hey" value="Submit"/>
</body>

JavaScript

$(document).ready(function () {
    $("#hey").click(function () {
        $.ajax({
            type: "GET",
            url: "http://maps.googleapis.com/maps/api/geocode/json",
            data: {
                "address": $("#hi").val(),
                    "sensor": false // this parameter should be added
            },
            dataType: 'json',
            success: function (response) {
                $("body").append("Address :" + response.results[0].formatted_address);
 $("body").append("<br>Latitude :" + response.results[0].geometry.location.lat);
 $("body").append("<br>Longitude :" + response.results[0].geometry.location.lng);               
               
            }

        });
    });

});