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

sidebar.html not showing

I don't know what I am doing wrong, but my sidebar.html content is not showing. Help?

<script> var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (xhr.readyState ===4) { documment.getElementById('ajax').innerHTML = xhr.responseText; } }; xhr.open('GET', 'sidebar.html'); xhr.send(); </script>

Tiffany White
Tiffany White
5,373 Points

Can you add your code in Markdown? Usually you want to enclose your code in three backticks ```. Then I can try to help. Check out the Markdown Cheatsheet below your post.

Tiffany White
Tiffany White
5,373 Points

I see what you're doing.

The sidebar will not show on the page. You will need to go to your browsers Developer Tools, go to the console, and when you refresh the page (or click on the button, depending on how far you've gotten) the console should read out that the xhr request was good, and that it pulled down the sidebar.html file.

So, just to follow up, you won't see the sidebar content. You will only see it in the browser's Developer Tools.

1 Answer

Benjamin Larson
Benjamin Larson
34,055 Points

Carina -

Your code just has a minor typo in spelling document as documment at this line:

document.getElementById('ajax').innerHTML = xhr.responseText;

Changing that should make the rest of your code work.