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

It's not working. Even the project files. Tried in Firefox and Chrome. Help.

Hi Guys,

I'm not getting anything in the console, although I should get the typeof xhr.responseText variable. I tried the fnished project files and I didn't get anything either.

What am I missing?

My code widget.js:

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

and the <head> of my html file:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>AJAX Office Status Widget</title>
  <link href='http://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
  <link rel="stylesheet" href="css/main.css">
  <script type="script/javascript" src="js/widget.js"></script>
</head>

Thanks.

5 Answers

Hi, Arek. I'm not sure what's going on. I tried copying and pasting your code into the console, and I am at the very least getting string back for the typeof xhr.responseText response. Maybe something else in your code is happening?

Something must be wrong. I took a snapshot of my workspace https://w.trhou.se/bczd5l6b3m, but it seems no files can be seen or opened.

Hmmm, that's really odd. Workspaces might be having an issue, then. You could try to contact support and see if they can take a look at it.

try switching it to wumbo? no in all seriousness i am having the same problem.

Thanks Ryan for help. I think you're right and this might be the case. I moved on to the next video and a new workspace and the code is working now. Phew!

Good to hear! :)

o/ just here to say a year later this bug happening for me as well