RSS

Tag Archives: geolocation

Get geographical location (geolocation) by IP address using jQuery

In my last post i wrote about how to get IP address in javascript. Now i am writing about how to get geoloaction by IP address. I have merged the code of previous post.

The code sample:

jQuery.getJSON(“http://jsonip.appspot.com?callback=?”,
function(data){
var clientip = data.ip;
var url =”http://freegeoip.net/json/”+clientip+”?callback=?”;
jQuery.getJSON(url, function(data){
$.each(data, function(key, val) {
alert(key+’ : ‘+val);
});
});
});

Advertisements
 
Leave a comment

Posted by on December 29, 2011 in javascript, jQuery

 

Tags: , , ,