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 trialMaureen O'Neal
12,930 PointsAjax callback challenge 3 of 4
I need hellp! I think I'm doing it right, but the challenge is rather nebulous in definition, so...here's my code, I'm calling the div in a new function with the send ajax! :
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('sidebar');
}
2 Answers
Brandon Barrette
20,485 PointsThis one is looking for the status check to be inside the ready state. So you need to remove the
xhr.readyState === 4 && xhr.status === 200
And instead move the xhr.status inside the xhr.readyState if statement body.
Maureen O'Neal
12,930 PointsThank you!! I got it! I knew I was on the wrong track, there! thanks!