JSFiddle - React, Tailwind, and code Playground
by kennsully
HTML
<body>
<p id="demo"></p>
</body>
JavaScript
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
myFunction(xhttp);
}
};
var location = 'istanbul'
xhttp.open("GET", "http://api.geonames.org/search?q= + location + &username=kennsully", true);
xhttp.send();
function myFunction(arg) {
var xmlDoc = arg.responseXML;
var geoid = xmlDoc.getElementsByTagName("geonameId")[1].childNodes[0].nodeValue;
document.write(geoid);
// console.log(geoid);
return geoid;
};
var geoid = myFunction();
console.log(geoid);