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

Jessica McGinn
Jessica McGinn
11,378 Points

JQuery and AJAX task 3 of 3

This is my code..dunno what's wrong with it but its not passing...

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

5 Answers

Jessica McGinn
Jessica McGinn
11,378 Points

Figured it out... to finish it I had to add the name of the function - 'response' - to the .html, silly mistake!

Thanks for all your help!

$.get("footer.html", function (response) {
$('#footer').html(response);
});
Dave McFarland
STAFF
Dave McFarland
Treehouse Teacher

Hi Jessica McGinn ,

Your code would work, but it's not what the code challenge is asking for. This particular challenge is asking you to use the technique where you pass an anonymous function in as the second argument to the $.get() method:

$.get("footer.html", function (response) {

});

However, your approach would work just fine in a real application.

Sorry for the confusion.

Sander de Wijs
PLUS
Sander de Wijs
Courses Plus Student 22,267 Points

You should add an anonymous function inside the $.get method

$.get("footer.html", function(response){
});
Jessica McGinn
Jessica McGinn
11,378 Points

Thanks both for your answers. So I've tried adding that:

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

Is this what you meant or am I missing the point :)

Dave McFarland
STAFF
Dave McFarland
Treehouse Teacher

Hi Jessica McGinn

You can get rid of this part:

var callback = function(response) {
   $('#footer').html();
};

Also the, $.get part should look like this:

$.get("footer.html", function (response) {

});