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

Andrei Punei
Andrei Punei
14,051 Points

How do you get the values from the JSON file??

The file is named employees.json altough in the callback function nested in the each method we used employee as defining the JSON file??

If you can provide employees.json so I can view how it's formatted I can supply a thorough expanation

1 Answer

Pedro Sousa
Pedro Sousa
18,545 Points

Hello Andrei,

I'm not 100% sure if I understood your question, but here's my try.

Did you noticed the data on the employees.json is an array? (everything is inside [ ]'s ).

Therefore, we are using query's .each function which takes an array, and a callback. You can name the parameters of the callback whatever you want.

For every position on the array, jQuery will call the callback and give it the current position to the first parameter and the current value to the second one.

Hope this helps.

Cheers, Pedro