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) jQuery and AJAX Add a callback

The Berserker
The Berserker
19,737 Points

Please Help with Jquery and AJAX Stage 3: Challenge task 1 of 3

Hey everyone! Thanks for reading! I have been the last 15 minutes trying to get past this part but I am unable. I know its a really simple answer, but for some reason I am blanking. The questions asks: You've got the $.get() method and first argument in place. The second argument to the $.get() method is a callback function. Pass an anonymous function as the second argument to the method. Don't forget to set a parameter for that function to catch the server's incoming response.

Help is appreciated, here is what I have.

$.get("footer.html"); var callback = function(response) {

};

What exactly am I missing? Thanks for the help!

5 Answers

Jack Choi
Jack Choi
11,420 Points

The code you have right now is analogous to:

$.get("footer.html");

var callback = function(response) {

};

The exercise asks for a callback function to be placed in the second argument of $.get() and currently the first argument is "footer.html". I don't want to quite give it away as it would sort of defeat the purpose of the challenges but I hope that might be enough hint to get you in the right direction?

The Berserker
The Berserker
19,737 Points

Hey Jack! Thanks a ton man! I realized that soon after and was able to get it. Thanks again for the help!

Matias Valenzuela
Matias Valenzuela
7,554 Points
var callback = function(response) {
};
$.get("footer.html", callback);

First you have to define the var and add it to the get method or it won't let you pass.

Levi Fulliton
Levi Fulliton
5,297 Points

$.get("footer.html", callback=function(response){});

This worked for me.

The Berserker
The Berserker
19,737 Points

Wait nevermind! I GOT IT LOL

Matthew Clark
Matthew Clark
7,255 Points

$.get("footer.html"); var callback = function(response) { };

What am I missing here? Above is my code.