Hi, would be great if you had an idea what is happening here - it works in an other test environment, but as soon as I want to use it in my Kirby project, the readyState keeps being 1 and it does not enter the ourRequest.open () function:
var btn = document.getElementById("send_btn");
btn.addEventListener("click", function() {
var ourRequest = new XMLHttpRequest();
ourRequest.open('GET', 'https://learnwebcode.github.io/json-example/animals-1.json');
console.log(ourRequest.readyState);
ourRequest.onload = function() {
alert(ourRequest.readyState);
if (ourRequest.status >= 200 && ourRequest.status < 400) {
var ourData = JSON.parse(ourRequest.responseText);
console.log(ourData);
} else {
console.log("We connected to the server, but it returned an error.");
}
};
ourRequest.onerror = function() {
console.log("Connection error");
};
});