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) AJAX Concepts A Simple AJAX Example

Chris George
Chris George
10,740 Points

Nothing Happening and I'm not sure why

I've looked over my code several times and don't see where my mistake is. Nothing happens in my browser and nothing appears in the console.

Screenshot of Workspace:

https://w.trhou.se/r51lz7wkp2

2 Answers

Jojo Menzies
Jojo Menzies
14,085 Points

you have a curly closing bracket on line 16. That's supposed to be the closing bracket for the conditional statement. Means it should be removed and inserted on line 13.

I forked your snapshot and moved the bracket to line 13 and it worked.

Chris George
Chris George
10,740 Points

Figured it out after completely deleting it and starting from scratch! Sometimes starting at code for hours makes you miss obvious mistakes and starting fresh clears your mind! Thanks for the reply :)

Chris Shaw
Chris Shaw
26,662 Points

Hi Chris George,

You should be at least getting an error as your script tag needs to be just before your closing </body> tag. The reason for this is the #ajax element doesn't exist at the time of the XHR request running.

Switching the placement of this code will result in it working.

Hope that helps.