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 Programming AJAX Parsing JSON Data

Tetsuya Yokoyama
Tetsuya Yokoyama
11,286 Points

The path from widget.js.....??? (Quick question)

Why is Dave using "data/employees.json" to access the file employees.json from widget.js?? Shouldn't it be "../data/employees/json" to access from widget.js? or do we have to use the path from index.html(which widget.js is linked in) Thanks in advance :)

1 Answer

Lachlan Stevens
Lachlan Stevens
10,779 Points

The path for a GET request is relative to the file that is making the request

While the function being called is defined in js/widget.js, it is index.html making the request, and thus the path is relative to this.

Tetsuya Yokoyama
Tetsuya Yokoyama
11,286 Points

Thank you very much that explains clearly!!

I had the exact same question. Thanks!