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

ARNAB ROY
PLUS
ARNAB ROY
Courses Plus Student 5,515 Points

What is wrong in the following Code.

Hi coded like this way but its not displaying the status of employee in the output. Please let me know what is the error on the code...

$(document).ready(function(){
  var url="../data/employees.json";
  $.getJSON(url,function(response(){
    var statusHtml='<ul class="bulleted">';
    $.each(response,function(index,value){
      var name=value.name;
      var status=value.inoffice;
      if(status===true){
        statusHtml+='<li class="in">';
      }else{
        statusHtml+='<li class="out">';
      }
      statusHtml+=name+'</li>';
    });
    statusHtml+='</ul>';
    $("#employeeList").html(statusHtml);
  }));//end GetJSON

});//End Ready

1 Answer

James Spence
James Spence
17,563 Points

You have an extra pair of brackets, it should look like this:

$.getJSON(url,function(response){
   // code...

});//end GetJSON
Dave McFarland
Dave McFarland
Treehouse Teacher

+1 James Spence

ARNAB ROY, you have a couple of extra parentheses in your code: There's an extra ( right after response and an extra ) at the line ending with //end GetJSON