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 Asynchronous Programming with JavaScript Asynchronous JavaScript with Callbacks Implement a Callback

Richard Preske
PLUS
Richard Preske
Courses Plus Student 4,355 Points

When debugging, this is error I get.

jquery.js:491 Uncaught TypeError: jQuery.each is not a function at jquery.js:491 at jquery.js:36 at jquery.js:40 (anonymous) @ jquery.js:491 (anonymous) @ jquery.js:36 (anonymous) @ jquery.js:40 ial.js:164 Uncaught ReferenceError: $ is not defined at ial.js:164 (anonymous) @ ial.js:164 csl.parser.js:2044 Uncaught ReferenceError: jQuery is not defined at csl.parser.js:2044 (anonymous) @ csl.parser.js:2044 extension.js:21 Uncaught TypeError: Cannot read property 'init' of undefined at Object.init (extension.js:21) at extension.js:45 at extension.js:48 init @ extension.js:21 (anonymous) @ extension.js:45 (anonymous) @ extension.js:48 callbacks.js:13 Uncaught TypeError: callback is not a function at XMLHttpRequest.xhr.onload

Not sure why it is saying callback is not a function. It seems there is something wrong with the requested data coming from Wikipedia or astroURL.

Steven Parker
Steven Parker
210,130 Points

Error messages are generally only useful when the code can be referenced, please also show the code.
Be sure to use Markdown formatting lor make a snapshot of your workspace and post the link to it here.

2 Answers

Steven Parker
Steven Parker
210,130 Points

The snapshot allowed me to replicate the issue and find it. :+1:

So on line 31 of "callbacks.js", there's an extra closing parenthesis, probably just a typo.

Richard Preske
Richard Preske
Courses Plus Student 4,355 Points

FIxed it, but still get error with only 2 astronauts. I get a 404 file not found error.

Steven Parker
Steven Parker
210,130 Points

That's not your program's fault. The API is listing a 3rd person as "Anatoly Ivanishin" (with a "y"), but the corresponding info page is under the name "Anatoli Ivanishin" (with an "i").

For a bonus exercise, you might try adding some code to make errors in looking up details a bit more graceful (like display the name and a "friendly" error message).