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 trialPeter Larson
6,412 Pointsemployee list doesn't show up
I re-typed the widget.js file from scratch, being careful to copy the code from the video exactly, and the employee list still doesn't show up.
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if(xhr.readyState === 4) {
var employees = JSON.parse(xhr.responseText);
var statusHTML = '<ul class="bulleted">';
for (var i=0; i<employees.length; i += 1) {
if (employees[i].inoffice === true) {
statusHTML += '<li class="in">';
} else {
statusHTML += '<li class="out">';
}
statusHTML += employees[i].name;
statusHTML += '</li>';
}
statusHTML += '</ul>';
document.getElementById('employeeList').innerHTML = statusHTML;
console.log(statusHTML);
}
};
xhr.open('GET', 'data/employees.json');
xhr.send();
console.log(statusHTML);
Snapshot: https://w.trhou.se/ctdomp248e
Peter Larson
6,412 PointsUpdated post with a snapshot link
4 Answers
Steven Parker
231,275 PointsThe snapshot did the trick! It did not appear that the script code was ever being loaded, so I added this at line 27 of index.html (just before the line with "</body>
"):
<script src="js/widget.js"></script>
After that, it seems to be working well.
Zoe Campbell
6,288 PointsI keep getting an uncaught syntax error on the last line, does anyone know the reason? https://w.trhou.se/gjhoj5bfnx
Steven Parker
231,275 PointsIt looks like your function is missing the final close brace (perhaps on line 18).
For future questions, always start a fresh question to give yourself the best chance of folks seeing and responding to it. I only saw that because I still had "follow" turned on from the last time I answered.
Vladimir Plokhotniuk
5,464 PointsHelp me pls. The same problem.... https://teamtreehouse.com/workspaces/36114242
Steven Parker
231,275 PointsPlease follow the advice I gave to Zoe and start a new question. Also, that's an unsharable direct URL to your workspace, it's temporary and only exists while you are using it. But you can use the snapshot function in the workspace and provide the link to that (not here, in the new question).
Vladimir Plokhotniuk
5,464 Pointssorry, this... https://w.trhou.se/dbj02s8ufu
Steven Parker
231,275 PointsPlease start a new question
This can be done easily using the "Get Help" button on the page. Then you can delete this "answer".
Vladimir Plokhotniuk
5,464 PointsMy employee list doesn't show up. https://w.trhou.se/dbj02s8ufu I compared with another answers, but it doesn't helped me
Steven Parker
231,275 PointsIt looks like you already created a new question for this issue, but forgot to post the link to the snapshot there.
I left an answer on that question. Please delete these "answers" from this one.
Steven Parker
231,275 PointsSteven Parker
231,275 PointsThere are other files involved in the display. To facilitate analysis, make a snapshot of your workspace and post the link to it here.