Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can we get country name through ip address using jquery [duplicate]

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

like image 394
user3446322 Avatar asked Jan 28 '15 07:01

user3446322


People also ask

How can I find the country of an IP address?

Overview: To obtain the details like country, continent, city, etc of the visitor, first we need to get the IP of the visitor. The IP address can be obtained with the help of superglobal $_SERVER in PHP. Finally, with the use of API geoPlugin, we can obtain information about the IP address i.e. visitor of the website.

How do I get the IP address of my computer using jquery?

ready(function () { $. get('http://jsonip.com', function (res) { $('p'). html('IP Address is: ' + res. ip); }); });


1 Answers

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;
});
like image 167
adeneo Avatar answered Oct 17 '22 06:10

adeneo