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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![balraj sarai](https://secure.gravatar.com/avatar/b8433a52212b91aef323ee1a03868716?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
balraj sarai
6,303 Pointsprogramming AJAX
Can you please check what the problem is with this code. I tried to do the rooms widget on my own. I do not get any errors, but the list comes undefined and in my employees list, instead of in the rooms list.
var xhr1 = new XMLHttpRequest();
xhr1.onreadystatechange = function () {
if(xhr1.readyState === 4 && xhr1.status === 200) {
var rooms = JSON.parse(xhr1.responseText);
var statusHTML1 = '<ul class="bulleted">';
for (var i=0; i<rooms.length; i += 1) {
if (rooms[i].available === true) {
statusHTML1 += '<li class="yes">';
} else {
statusHTML1 += '<li class="no">';
}
statusHTML1 += rooms[i].room;
statusHTML1 += '</li>';
}
statusHTML += '</ul>';
document.getElementById('roomList').innerHTML = statusHTML;
}
};
xhr.open('GET', '../data/rooms.json');
xhr.send();
David Mandel
33,158 PointsTwo possible problems:
1) Class name for the unordered list has changed. It should now be:
'<ul class="rooms">'
2) Using the right class name for the list items. I think you need to change your if/else statement so that if true,
statusHTML += '<li class="empty">';
And then if false the class name would be full.
Hope that helps!
1 Answer
![balraj sarai](https://secure.gravatar.com/avatar/b8433a52212b91aef323ee1a03868716?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
balraj sarai
6,303 Pointsvar statusHTML1 = '<ul class="rooms">';
i forgot to change the class name of this (above), and also forgot to change the variable names (below) to xhr1.
xhr1.open('GET', '../data/rooms.json');
xhr1.send();
but thank you all for your replies.
Aurelian Spodarec
7,369 PointsAurelian Spodarec
7,369 Pointshi , i sugest you to add
var your code here
``
javascript# and then close without hte phone sign adding three of that
at the end of your code on next lineit will make easier and faster for peopel that will help you