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 trialMauro Bonucci
5,953 PointsStatus Server 200
Cant pass this challenge, somethings is wrong, i leave my code above:
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4){
xhr.readyState === 200)
}
};
xhr.open('GET', 'sidebar.html');
xhr.send();
3 Answers
Dave McFarland
Treehouse TeacherYou need to check that the readyState
is 4 AND that the status
is 200. That requires using a conditional statement with an AND operator like this:
if (xhr.readyState === 4 && xhr.status === 200) {
}
Robert Bojor
Courses Plus Student 29,439 PointsHi Mauro,
You have an extra ) right after 200, plus you don't set the readyState to 200, no point for that. Check the code below
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4){ /* Do whatever logic is needed */ }
};
xhr.open('GET', 'sidebar.html');
xhr.send();
Mauro Bonucci
5,953 PointsYour right :-S, thanks Robert