XHR
by sjmcpherson
HTML
<script src="https://smart-ip.net/geoip-json?callback=myHandler"></script>
<div id="myDiv">error</div>
JavaScript
(function(){
alert(myHandler());
});
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
//console.log(xhr.readyState + " " + xhr.status);
if (xhr.readyState == 4 && xhr.status == 200)
{
//Parse the JSON data
document.getElementById("myDiv").innerHTML=xhr.responseText;
}
}
xhr.open("GET","https://smart-ip.net/geoip-json?callback=?", true);
//xhr.send();