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 is in the wrong location

My employee status is showing up after all the paragraph text, instead of on the right hand sidebar. Any ideas??

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

It could be something simple like the html you're generating having a missing or mismatched closing tag. Would you be able to post your code so we can have a look? :)

I have added the js code. Which I copied exactly from the lesson. I do not see any differences.

4 Answers

Mark Wilkowske
PLUS
Mark Wilkowske
Courses Plus Student 18,131 Points

Hi Michelle, this sounds like what I saw today but then I remembered Treehouse is Responsive so I resized the browser window to >= 1280px wide and the status shifted to where it should be.

That was exactly the issue. Thank you, I did not even consider the responsiveness.

Maybe you have a typo in the selected html output element's id?

The id of the html element that the generated html should be injected into, should be addressed like this in your code:

 document.getElementById('employeeList').innerHTML = statusHTML;

employeeList is the html element's id in this challenge.

$(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

Hm your jQuery Code is fine. I can't see any mistakes.

Must be something in your html then. Did you change something in the html file?