Getting the country in browser require user to approve. But what if the user doesn't approve. Here is a way to get users location using JQuery.
$.ajax({
url: "https://geolocation-db.com/jsonp/ee33e930-db78-11eb-9218-377a93e0222e",
jsonpCallback: "callback",
dataType: "jsonp",
success: function (location) {
$('#country').html(location.country_name);
$('#state').html(location.state);
$('#city').html(location.city);
$('#latitude').html(location.latitude);
$('#longitude').html(location.longitude);
$('#ip').html(location.IPv4);
}
});
More details : https://geolocation-db.com/documentation
Happy coding..
No comments:
Post a Comment