var ajax = new XMLHttpRequest(); ajax.open("GET", "http://api.rest7.com/v1/ip_to_city.php?ip=123.45.67.89", true); ajax.responseType = "json"; ajax.onreadystatechange = function() { if (ajax.readyState === 4 && ajax.response.success === 1) { alert( "Country: " + ajax.response.country + "\r\n" + "Region: " + ajax.response.region + "\r\n" + "City: " + ajax.response.city + "\r\n" + "Latitude: " + ajax.response.lat + "\r\n" + "Longitude: " + ajax.response.lng + "\r\n" ); } } ajax.send();