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

Tommy Gebru
Tommy Gebru
30,164 Points

My list will not show in Workspace's preview

AJAX Basics - The Office Status Project Revisited

No obvious error .... working on Chrome browser :smile:

$(document).ready(function (){
$.getJSON('../data/employees.json', function (response){
  var statusHTML = '<ul class="bulleted">';//open ul
  $.each(response, function(index, employee){
    if(employee.inoffice === true){
      statusHTML += '<li class = "in">';//create in
    }
    else { 
            statusHTML += '<li class = "out">';//create out
    }//end if
            statusHTML += employee.name + '</li>'; 
  });//end each
       statusHTML += '</ul>';//close ul
        $('#employeeList').html = statusHTML;//update HTML
});//end JSON
});//end ready

1 Answer

Adam Mould
Adam Mould
6,292 Points

Hi Tommy,

Change your line:

$('#employeeList').html = statusHTML;//update HTML

to ...

$('#employeeList').html(statusHTML);//update HTML

alternatively you could use ...

$('#employeeList')[0].innerHTML = statusHTML;//update HTML

document.getElementById('employeeList').innerHTML = statusHTML;//update HTML

Hope that helps.

Tommy Gebru
Tommy Gebru
30,164 Points

thanks for the second pair of eyes!