Here i use GeoLite Data base.
In program i use a cdn to get location.
This program return JSON Object which Contain location releted information.
<pre class="lang:js"><script type="text/javascript" src="https://js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js"></script>
<script type="text/javascript">
var onSuccess = function(location){
alert(
"Lookup successful:\n\n"
+ JSON.stringify(location, undefined, 4)
);
alert( JSON.stringify(location));
};
var onError = function(error){
alert(
"Error:\n\n"
+ JSON.stringify(error, undefined, 4)
);
};
geoip2.city(onSuccess, onError);
</script></pre>
No comments:
Post a Comment