Friday, December 25, 2015

How to get end user's details in jquery

Get end user's details in jquery:

For getting all the details of any user who is using your website we have to use the following trick:

In this details we can get user's
country name,
city name,
region name,
latitude,
longitude,
ip address,
country code.

For this firstly we have to include jquery library which you can include from here.

Now write this function:



function goToPage() {
    jQuery.ajax({
        url: '//freegeoip.net/json/',
        type: 'POST',
        dataType: 'jsonp',
        success: function (location) {
            var ip=location.ip ;

            var country=location.country_name;
            var country_code= location.country_code;
            var city= location.city ;
            var region=location.region_name;
            var lat= location.latitude;
            var lng=location.longitude;
        }
    });
}



You can use this function where you want.

Thanks

No comments:

Post a Comment