2017  Kodetalk | Feedback | Privacy Policy | Terms | About

How to get the user country name from Clint side using JQuery.

I am working on a requirement where we need to find the country name for the registration user without any burden giving to the user to select the country name manually. That"s why am looking for a solution to get the user country name from client side by using javascript or jquery. First of all I want to confirm that, is the requirement valid or not. And if yes then how we can track the user country name automatically without any user interruption.

Yes, its possible. We can able track the user country name from the client side using JQuery by invoking  the 3rd party URL through Ajax call.

Please find the example here,

<script language="javascript" type="text/javascript" src="https://code.jquery.com/jquery-3.0.0.min.js"></script>



        $.getJSON("http://freegeoip.net/json/", function(data) {

            var country = data.country_name;

            alert("country " + country);




The request url will give the below result. Now its depends on your choice whatever the data need from the user at the time of registration.


Answer is