Attempting to utilize AJAX to retrieve JSON data for a Greasemonkey script.
The current setup is as follows:
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var xmlresult = JSON.parse(this.response);
// successful operation
console.log(xmlresult);
}
};
xmlhttp.open("GET", "https://raw.githubusercontent.com/mledoze/countries/master/countries.json", true);
xmlhttp.send();
// unsuccessful operation
console.log(xmlresult);
An issue arises where xmlresult
remains empty consistently. Despite there being visible data in the response when inspected directly via the console, any attempts to manipulate it beyond the specified if block are futile.