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

Lewis Turner
Lewis Turner
10,930 Points

Failed to load resource: the server responded with a status of 404 (Not Found)

Hi

I am getting the above error in workspaces. I have checked and re-checked my code but I can't figure out what is causing it...

var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
  if (xhr.readyState === 4) {
    var employees = JSON.parse(xhr.responseText);
   }
};
xhr.open('GET', 'data/employees.json');
xhr.send();

https://teamtreehouse.com/workspaces/16510372#

Any help would be much appreciated!

Cheers

Lewis

Lewis Turner
Lewis Turner
10,930 Points

Aah, thats annoying. It works for me :(

This is my code...

var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
  if (xhr.readyState === 4) {
    var employees = JSON.parse(xhr.responseText);
   }
};
xhr.open('GET', 'data/employees.json');
xhr.send();

2 Answers

Lewis Turner
Lewis Turner
10,930 Points

Crisis averted. I deleted the workspace, loaded it up again, pasted my js back in and re-added the script tag, and it worked. Workspaces was obviously having a bit of a moment! :o)

Lewis Turner
Lewis Turner
10,930 Points

Me either. I was well and truly stuck!