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 trialyitan
8,640 PointsNow use a DOM element's innerHTML property to set the HTML inside the sidebar div to the server's response.
I typed as follows: document.getElementById('sidebar').innerHTML = xhr.responseText; But it can not pass the check...
8 Answers
Dave McFarland
Treehouse TeacherGood catch. There is a problem with the Code Challenge. We're working to get that fixed. Sorry for the inconvenience.
Aidan Lowson
10,379 PointsHere is my solution:
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if(xhr.readyState === 4) {
if(xhr.status === 200) {
document.getElementById('sidebar').innerHTML = xhr.responseText;
}
}
};
xhr.open('GET', 'sidebar.html');
xhr.send();
Dave McFarland
Treehouse TeacherHi yitan and Luca Terrigno
That code challenge is now fixed. Thanks for the heads up on it.
Alessandro Zerillo
7,379 Pointsi think there is still a problem
Dave McFarland
Treehouse TeacherAlessandro Zerillo can you post the code that you're using in the code challenge?
Rafael Marrero
4,775 PointsHi,
I'm having the same issue as above, here is my code that works but the test isn't passing.
var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { let sidebar = document.getElementById('sidebar'); console.log(xhr.responseText); sidebar.innerHTML = xhr.responseText; } }; xhr.open('GET', 'sidebar.html'); xhr.send();
Tommy Choe
38,156 PointsI tried copying and pasting your code directly into the challenge and it seems to work just fine for me. Check to see if you added any extra characters somewhere else.
John Norris
21,145 PointsHere's my solution:
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4, xhr.status === 200) {
document.getElementById('sidebar').innerHTML =xhr.responseText;
}
};
xhr.open('GET', 'sidebar.html');
xhr.send();
Patrick Ho
Courses Plus Student 6,412 PointsDave, Do u mind to check again cause i can't past the test with the same problem
Dave McFarland
Treehouse TeacherCan you post the code that you are trying?
Patrick Ho
Courses Plus Student 6,412 Pointsif(xhr.readyState === 4 && xhr.status === 200) {
document.getElementById('sidebar').innerHTML = xhr.responeText;
}
Dave McFarland
Treehouse TeacherHere's the problem Patrick: xhr.responeText
Is should be response
not respone
Patrick Ho
Courses Plus Student 6,412 Pointsopps...... didn't found out the problem~~ sorry for disturb and thank for the solution~~
Luca Terrigno
4,103 PointsLuca Terrigno
4,103 PointsI'm having the same issue. I went through my notes and previous Workspace and it shows this example and how it needs to be implemented which is exactly what I'm typing in for the code challenge. Any other suggestions.