Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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>"