<script type="text/javascript" src="//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js"></script>
<script type="text/javascript">
var onSuccess = function(location){
var x = JSON.stringify(location, undefined, 3);
document.write(x);
return x;
};
var onError = function(error){
alert(
"Error:\n\n"
+ JSON.stringify(error, undefined, 3)
);
};
geoip2.city(onSuccess, onError);
</script>