Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics (retiring) AJAX Concepts A Simple AJAX Example

ReferenceError when running my ajax example

I can't quite figure out what is wrong with my code. I'm following the video to the letter, but as I run it and bring up the console it states the HMLHttpRequest is undefined.

<script> var xhr = new HMLHttpRequest(); // AJAX Object xhr.onreadystatechange = function () { if ( xhr.readyState === 4 ) { document.getElementById('ajax').innerHTML = xhr.responseText; } }; // Callback Function xhr.open('GET', 'sidebar.html'); // Open a request function sendAJAX() { xhr.send(); // Send request document.getElementById( 'load' ).style.display = "none"; } </script>

2 Answers

You misspelled XMLHttpRequest as HMLHttpRequest, which is undefined. Small mistakes can go unnoticed.

Hope this helps

I was slowly going insane there for a moment. A second pair of eyes did the trick. Thank you