Answer the question
In order to leave comments, you need to log in
How to use the parsed data in another file?
varxhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.send();
xhr.onreadystatechange = function() {
if (xhr.readyState != 4) return;
if (xhr.status != 200) {
alert(xhr.status + ': ' + xhr.statusText);
} else {
var eventsList = JSON.parse(xhr.responseText)
}
console.log(eventsList);
}
After parsing, I get an object with data. I can extract everything I need from it, but only within the function. How to redefine variables so that they can be used in other files (or just outside the scope of this function)? I'm completely confused .. Help, please !!
Thank you!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question