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

General Discussion

Ajax Calback challenge 3 of 4

I can;t figure out what this challenge WANTS! It asks you to call the div, I assumed they want it to be in a separate function, it really doesn't TELL you what they the page is supposed to look like, or anything. Anyway, here's my code, that doesn't pass: var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(){ if(xhr..readystate ===4 && xhr.status === 200){ document.getElementById('ajax').innerHTML = xhr.responseText; } }; xhr.open('GET', 'sidebar.html'); function sendAjax(){ xhr.send(); document.getElementById('div'); }; Thanks!

correction, that should read document.getElementById('sidebar'); for the last line, still doesn't pass.

2 Answers

No, that sendAjax function is unnecessary. After the xhr.open statement you just need to send the request with xhr.send()

Yes, I got it! I was concerned about the document.getelementbyId, but I put it up in the original function, and it worked!