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

Trying to follow along with Parsing JSON Data video but getting error

When I try to follow along with this video, including opening the console, I get an error message that appears to be rooted in the 4th line of my widget.js, and specifically with the content inside the console.log().

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

When I put my cursor over the content of my console.log, I get the following msg:

"Uncaught SyntaxError: missing ) after argument list"

I'm not seeing why there's an error here, and hoping another pair of eyes can spot it.

2 Answers

andren
andren
28,558 Points

The typeof operator should be written all in lowercase, not in camelCase like it is in your code. If you change its name like this:

console.log(typeof xhr.responseText);

Then that will likely fix that error.

Thank you!