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