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) 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,676 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.