I'm running a simple AJAX request:
function makePages(num) {
var conn = new XMLHttpRequest();
conn.onreadystatechange = function() {
if (conn.status === 200 && conn.readyState === 4) { //error here
$('#oldPost').before(conn.responseText);
}
else{
return
}
}
conn.open('GET','includes/feedExtra.php?num=' + num);
conn.send();
}
The code runs correctly and the PHP returns the correct content. However, there is an error in Chrome's console:
Uncaught Error: InvalidStateError: DOM Exception 11
it points to this line:
if (conn.status === 200 && conn.readyState === 4) {
What am I doing wrong?