Monday 9 April 2018

Get visitor’s location, city, country,IPAddress using JavaScript and JQuery.

Get visitor’s location, city, country,IPAddress using JavaScript and JQuery.

Description:


In this example we explain that how to get User Location and IP address using JavaScript and JQuery. or how to get country based on IP Address in JavaScript and jQuery. or how to get user machine address information like (country, IP address, State, Zip code etc..) where the user actually accesses our website using JavaScript and jQuery.

So here we demonstrate that how to get end user Location information through web service in JavaScript. Or how to get User Location information like Country and IP address at client side using JavaScript and JQuery.
Script Code:

  $.getJSON('//freegeoip.net/json/?callback=?', function (data) {
            // console.log(JSON.stringify(data, null, 2));

            $("#hdncountry").val(data["country_name"]); // here you get the country of the user
            $("#ddlcountry").val(data["country_name"]);

            // alert(data["country_name"]);
        });



0 comments:

Post a Comment