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
Tani Huang
6,952 Pointswhat are (response) and employee stand for ? (JSON question)
[
{
"name": "Aimee",
"inoffice": false
},
{
"name": "Amit",
"inoffice": false
}
]
var url = "../data/employees.json";//JSON data
$.getJSON (url,function(response) {//response is stand for ? response = JSON data?
var statusHTML = "<ul class="bulleted">";
$.each(response,function(index,employee){//index = number , employee stand for ?
if (employee.inoffice === true) {
statusHTML += "<li class="in">";
} else {
statusHTML += "<li class="out">";
}
statusHTML += employee.name + "</li>";
});
statusHTML += "</ul>";
$("#employeeList").html(statusHTML);
});
Link of the video:
https://teamtreehouse.com/library/ajax-basics/jquery-and-ajax/the-office-status-project-revisited
Formula of jQuery
$.getJSON (url,callback);
$.each(array,function(index,value) { });
1 Answer
Steven Parker
243,656 PointsIn this code, "response" is the name of the parameter which holds the incoming JSON data, which is an array of employee info.
Then "employee" is the parameter which holds an individual employee record, as separated out by the "each" function.
And every "employee" has two properties, "name" and "inoffice'.