🔊 jQuery - Geolocation
Updated at 2013-05-07 13:49
You can get geolocation easily using jQuery and free APIs.
// Define some variables
var ip = '86.50.88.167';
var api = 'http://freegeoip.net/json/' + ip + '?callback=?';
$.getJSON(api, function(location) {
// location has bunch of stuff e.g. latitude, longitude, zipcode.
var city = location.city;
var country = location.country_name;
console.log('How is the weather in '+city+', '+country+'?');
});