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

Mohsen Qaddoura
Mohsen Qaddoura
22,237 Points

jquery and ajax office status project sidebar employeeList div is not rendered

query and ajax office status project sidebar employeeList div is not rendered here is my widget.js :

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

And index.html header:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>AJAX Office Status Widget</title> <link href='http://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="css/main.css"> <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> <script src="js/widget.js"></script> </head>

2 Answers

Mohsen Qaddoura
Mohsen Qaddoura
22,237 Points

I resolved the issue just now, If you check my code above you will find out that I forgot to close the parentheses for the getJSON function like this: }); // end getJSON This was the only issue!

Thanks for the reply.

Misha Shaposhnikov
Misha Shaposhnikov
8,718 Points

You forgot to add the <li> and </li> tags between the employee names.

Should be like this:

var statusHTML = "<ul class='bulleted'>";
    $.each(response, function (index,employee) {
        statusHTML += '<li class="in">'
        statusHTML += '<li class="out">'

      statusHTML += employee.name + '</li>'
      });   // end each
      statusHTML += "</ul>"