IP Geolocation

by dledle2

HTML

<h3>Client side IP geolocation using <a href="//ipinfo.io">ipinfo.io</a></h3>

<hr/>
<div id="ip"></div>
<div id="address"></div>
<hr/>Full response: <pre id="details"></pre>

<div id="my_div"></div>

JavaScript

$.get('//ipinfo.io', function(data2) {
/* console.log($(data)); */
 console.log( 'Location_' + data2.city + "_" + data2.region  );
   /*  var my_div = $('#my_div', $(data).html); */
}, "jsonp");


$.get("//ipinfo.io", function (response) {
    console.log( response.city + ", " + response.region  );
    $("#ip").html("IP: " + response.ip);
    $("#address").html("Location: " + response.city + ", " + response.region);
    $("#details").html(JSON.stringify(response, null, 4));

    
}, "jsonp");