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 trialTejas Potdar
6,594 PointsEmployee Status does not load in Chrome
I used the exact code in the workspace and then refreshed the browser (Chrome) but it did not load. Please help.
Dave McFarland
Treehouse TeacherHave you looked in the the JavaScript console for any errors?
Josuel Garcia
6,069 PointsEven when I use your finished code Dave google chrome will not load the employee status there are no errors in the console
$(document).ready(function () {
$.getJSON('../data/employees.json', function (data) {
var statusHTML = '<ul class="bulleted">';
$.each(data,function (index, employee) {
if (employee.inoffice === true) {
statusHTML +='<li class="in">';
} else {
statusHTML +='<li class="out">';
}
statusHTML += employee.name + '</li>';
});
statusHTML += '</ul>';
$('#employeeList').html(statusHTML)
}); // end getJSON
}); // end ready
Dave McFarland
Treehouse TeacherHow are you previewing this? In Workspaces?
Josuel Garcia
6,069 PointsDave McFarland yes workspace
Dave McFarland
Treehouse TeacherWhat happens if you open the workspace, preview it, then in the previewed tab add this to the end of the URL: finished/ In other words the finished URL should look something like this: http://port-80-66fecqc47b.treehouse-app.com/__finished__/
What are you seeing? Is the right-hand sidebar just blank?
Josuel Garcia
6,069 Pointsok so when i add finished/ to the end of the url the employee status does load. it works lol so now what Dave McFarland
Dave McFarland
Treehouse TeacherIs there a data
folder and inside that is there an employees.json
file? Also check to make sure that file has information in it.
4 Answers
Red Zylo
6,108 PointsCheck the JavaScript console. I had the same problem until I realized I forgot to put a single quote at the end of line 4.
Jennifer Hughes
11,421 PointsI am now having the same problem: I get all of the names to load, the the status is not appearing next to the name. I've reviewed my code several times and I cannot find an error. Any ideas?
$(document).ready(function() {
var url= "../data/employees.json";
$.getJSON(url, function (response){
var statusHTML = '<ul class "bulleted">';
$.each(response, function(index, employee) {
if (employee.inoffice === true) {
statusHTML+='<li class="in">';
} else {
statusHTML+='<li class="out">';
}
statusHTML+=employee.name +'</li>';
});
statusHTML+='</ul>';
$('#employeeList').html(statusHTML);
}); //end getJSON
});// end ready
Dave McFarland
Treehouse TeacherJennifer Hughes
The problem is on this line of your code:
var statusHTML = 'ul class "bulleted">';
The HTML inside the string is incorrect, you need to place an = sign between class
and "bulleted"
like this: `
var statusHTML = '<ul class="bulleted">';
Jennifer Hughes
11,421 PointsHi, Dave!
How strange, yesterday I tried it both ways, and neither worked. Today, I added the = sign back in, and wa-la! Magic. Go figure.
Cheers.
Ethan Lowry
Courses Plus Student 7,323 PointsEthan Lowry
Courses Plus Student 7,323 PointsHi, please post all the code you're running here, just in case, so people can help better.