A common Asynchronous request is made by the following:
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://localhost:1337/test.php", true);
xhr.onload = function (e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
abc = xhr.responseText;
} else {
console.error(xhr.statusText);
}
}
};
a = JSON.parse(abc);
I get the following error:
Uncaught ReferenceError: abc is not defined
What is going wrong here?