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

Romain Gaget
Romain Gaget
24,449 Points

What's wrong with My CODE????

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

2 Answers

Gergő Bogdán
Gergő Bogdán
6,664 Points
$.get("/footer.html", function(response){$('#footer').html(response);});

I think you are missing a / from the request AND you do NOT need to name your function. That is an anonymus function which is placed inline, so there is no need for a name.

You can also use a second function parameter which handles the errors:

$.get("/footer.html", function(response){$('#footer').html(response);}, function(errorMessage) { console.log(errorMessage);});
Romain Gaget
Romain Gaget
24,449 Points

Yes Thank you it worked, the problem was that I name my function on step 2 which was fine but didn't accept it on step 3...weird!! Anyway thanks for your help!