czar85e
6/12/2013 - 11:10 PM

Find the geographic location of an IP address

Find the geographic location of an IP address

$.get('http://jsonip.com/', function(r){ console.log(r.ip); });

var ip = '', // you can optionally put an ip address here
api = 'http://freegeoip.net/json/' + ip + '?callback=?';
$.getJSON(api, function(r){
  console.log('How is the weather in ' + r.city + ', ' + r.country_name + '?');
});