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
Anthony Santiago
10,082 PointsCode only works in workspaces, not outside via another text editor.
My code works for the most part, but am having issues with AJAX/j Query. The "Office Status Project" never displayed the additional html, nor did the employee list show up when using notepad++, but when I copied and pasted the code in workspaces, it worked just fine.
Any reason why?
Anthony Santiago
10,082 Pointshttps://w.trhou.se/zc2p5f4zuk
$(document).ready(function () { var url = '../data/employees.json'; $.getJSON(url, function (response) { var statusHTML = '<ul class="bulleted">'; $.each(response, 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); });
});
1 Answer
Chyno Deluxe
16,936 PointsI was able to get it working correctly on jsFiddle. Are you sure you have your files linked correctly in your local machine?
Anthony Santiago
10,082 Pointsyes, I downloaded the source files first, I also copied and pasted the code into documents and folders I created manually, just to make sure. employee list just doesn't want to pop up. i will try to see if it is at least reading the json file, i have had issues with the jQuery source being linked to the jquery.com cdn before and linked it to google's library.
Anthony Santiago
10,082 PointsI was able to get it to work with firefox, but not with chrome or IE (all are updated). It was only when I removed the "../" in the url that it showed up, otherwise it was not reading the file.
Strange....
Chyno Deluxe
16,936 Pointswas it structured as it was on the workspace? I used chrome as well and had no issues.
If it was then yes. Very strange. but glad you were able to get it working.
Anthony Santiago
10,082 Pointsyes, it seemed to have worked in IE, but still not in chrome. This is just me going into the downloaded content and opening the 'index.html' file from the finished folder that comes with the downloads...it is weird, but I will take a small victory where I can.
Thanks for the help, I got the idea to mess with the url after seeing your url link on the jsFiddle code.
Chyno Deluxe
16,936 PointsGlad I can point you in the right direction.
Chyno Deluxe
16,936 PointsChyno Deluxe
16,936 PointsCan you post a snapshot of your workspace.