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
Ben Goldman
14,626 PointsAjax Employee Status Project
I recently did the Ajax Basics course. There was a project where you load in a status list of employees using JSON. Basically, to see who is in the office and who is out. I put the files on my local Xamp server, but they are not being loaded to the page. I checked my project against the finished project that I downloaded from Treehouse. I couldn't see any difference. I swapped out my code for the coded project that I downloaded from Treehouse. Again, nothing is being loaded. The JS console is showing a 404 error on both of those files when the browser looks for them to load. I have a folder in htdocs named 'officeapp' and within that folder I have all of the associated project files. The 'employees' and 'rooms' files are in another folder called 'data' just like in the lesson. I really appreciate any help I can get with this. It's driving me a little nuts. Thanks!
$(document).ready(function () {
$.getJSON('../data/employees.json', function (data) {
var statusHTML = '<ul class="bulleted">';
$.each(data, function (index, employee) {
if (employee.inoffice === true) {
statusHTML +='<li class="in">';
} else {
statusHTML +='<li class="out">';
}
statusHTML += employee.name + '</li>';
});
statusHTML += '</ul>';
$('#employeeList').html(statusHTML)
}); // end getJSON
$.getJSON('../data/rooms.json', function (data) {
var statusHTML = '<ul class="rooms">';
$.each(data, function (index, room) {
if (room.available === true) {
statusHTML +='<li class="empty">';
} else {
statusHTML +='<li class="full">';
}
statusHTML += room.room + '</li>';
});
statusHTML += '</ul>';
$('#roomList').html(statusHTML)
}); // end getJSON
}); // end ready
Yazeed Bzadough
4,880 PointsYes Ben, I had a similar problem. Putting "../" before the data's URL gave me a 404 error as well. Glad to see you solved it.
1 Answer
Kristin Berlehner
26,734 PointsI had the same problem. It was driving me nutzo! Thank you! :)
Ben Goldman
14,626 PointsBen Goldman
14,626 PointsProblem solved. For some reason, the url shorthand wasn't working. So I had to write out all of the folder names and then it worked perfectly.