Feeling a bit out of practice here - used to work with AJAX directly, but then spent a few years on a jQuery site and now my native JS skills are rusty.
I've simplified my code as much as possible, but it's still not functioning:
var rawfile = new XMLHttpRequest();
rawfile.onreadystatechange = function() {
console.log(rawfile.readyState);
}
rawfile.open("GET", "index.html", true);
The expected output should be
1
2
3
4
but all I'm getting is
1
I can't seem to find any issues in the code. Is there something obvious that I'm missing?