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 trialSamuel Kleos
Front End Web Development Techdegree Student 13,307 Points../data/rooms.json -> Status 404
Here is my code for the XMLHttp request:
var roomsJSON = new XMLHttpRequest();
roomsJSON.onreadystatechange = function() {
if (roomsJSON.readyState === 4) {
if (roomsJSON.status === 200) {
const rooms = JSON.parse(roomsJSON.responseText);
for (let room of rooms) { console.log(rooms) }
} else {
console.log(roomsJSON.status);
}
}
};
roomsJSON.open('GET', "../data/rooms.json");
roomsJSON.send();
Console Output:
> GET http://port-80-5dezzhp748.treehouse-app.com/data/rooms.json 404 (Not Found)
> 404
> XHR finished loading: GET "http://port-80-5dezzhp748.treehouse-app.com/data/employees.json".
> XHR failed loading: GET "http://port-80-5dezzhp748.treehouse-app.com/data/rooms.json".
Cheers 🙏🏼
2 Answers
Rohald van Merode
Treehouse StaffHi Samuel 👋
I just had a look at the workspace but the rooms.json
file should be present when opening the workspace for this video. If you still have a workspace open from the previous videos in this course you may want to try and close it to then launch the one connected to this video.
To avoid anyone else running into this issue in the future I've just updated the files from the previous workspaces to include that same rooms.json
file 🙂
Steven Parker
231,268 PointsThe code is looking for a file named "rooms.json" in the "data" directory, but there is no such file in workspace environment. Did one perhaps get deleted by mistake?
Samuel Kleos
Front End Web Development Techdegree Student 13,307 PointsI'm not sure. I'm just following the instructions and forked the same workspace from this video:
https://teamtreehouse.com/library/ajax-basics-2/programming-ajax-challenge
Steven Parker
231,268 PointsSteven Parker
231,268 PointsTo make it possible to replicate your issue, you can make a snapshot of your workspace and share the link to it here.