5

Please help me to find the country name through ip address using jquery or JavaScript.

I am using this code for getting the ip address. But I am not getting any idea how can we get the country name using the IP Address. Please help me.

<script>
    $.getJSON("http://jsonip.com?callback=?", function (data) {
     alert("Your ip: " + data.ip);
 });
</script>

Please help me

user3446322
  • 129
  • 1
  • 2
  • 11

1 Answers1

26

Use a service that actually returns countrynames, like FreeGeoIp

$.getJSON("http://freegeoip.net/json/", function (data) {
    var country = data.country_name;
    var ip = data.ip;
});
adeneo
  • 312,895
  • 29
  • 395
  • 388