RSS

Get geographical location (geolocation) by IP address using jQuery

29 Dec

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: , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: