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

JavaScript AJAX Basics (retiring) jQuery and AJAX The Office Status Project Revisited

Employee 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.

Ethan Lowry
Ethan Lowry
Courses Plus Student 7,323 Points

Hi, please post all the code you're running here, just in case, so people can help better.

Dave McFarland
Dave McFarland
Treehouse Teacher

Have you looked in the the JavaScript console for any errors?

Even 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
Dave McFarland
Treehouse Teacher

Josuel Garcia

How are you previewing this? In Workspaces?

Dave McFarland yes workspace

Dave McFarland
Dave McFarland
Treehouse Teacher

Josuel Garcia

What 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?

ok 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
Dave McFarland
Treehouse Teacher

Josuel Garcia

Is 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
Red Zylo
6,108 Points

Check 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
Jennifer Hughes
11,421 Points

I 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
STAFF
Dave McFarland
Treehouse Teacher

Jennifer 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
Jennifer Hughes
11,421 Points

Hi, 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.