Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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');

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

28,521 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!