<!DOCTYPE html>
<html>
<head>
<script>
var xmlhttp = new XMLHttpRequest();
var url = "http://freegeoip.net/json/";
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = JSON.parse(xmlhttp.responseText);
document.getElementById("demo").innerHTML =
obj.city + "," + obj.region_name + "," +obj.country_name + ""
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
</script>
</head>
<body>
<div id="demo"></div>
</body>
</html>
<!--campi-->
<!--attn il + non si mette per l'ultimo campo-->
<!-- obj.ip+ "<br>" + -->
<!-- obj.country_code + "<br>" + -->
<!-- obj.country_name + "<br>" +-->
<!-- obj.region_code + "<br>" + -->
<!-- obj.region_name + "<br>" + -->
<!-- obj.city + "<br>" + -->
<!-- obj.zipcode + "<br>" + -->
<!-- obj.latitude + "<br>" + -->
<!-- obj.longitude;-->