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
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.
ready(function () { $. get('http://jsonip.com', function (res) { $('p'). html('IP Address is: ' + res. ip); }); });
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;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With