JavaScript AJAX Basics (retiring) Programming AJAX Create a callback

Christopher Baxter
PRO
Christopher Baxter
Pro Student 558 Points

Why is the anonymous function not being accepted in my AJAX callback?

Syntax appears to be correct according to earlier examples given in previous videos but still coming back with an error when I click 'check work'. Any help would be appreciated.

app.js
var xhr = new XMLHttpRequest();
xhr.onReadyStateChange = function () {
};

xhr.open('GET', 'sidebar.html');
xhr.send();
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>AJAX with JavaScript</title>
  <script src="app.js"></script>
</head>
<body>
  <div id="main">
    <h1>AJAX!</h1>
  </div>
  <div id="sidebar"></div>
</body>
</html>

1 Answer

Christopher Baxter
Christopher Baxter
Pro Student 558 Points

Hi Kris, Spotted this just after posting the question, got to love those typos! Many thanks for responding to the question, much appreciated.