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

Charles Harpke
Charles Harpke
33,986 Points

Inside the anonymous function, use jQuery to select the footer div. It has an ID of 'footer'.

Any hints here? What method is being used inside of the anonymous function?

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

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Charles,

If you remember back to selector basics we use jQuery's DOM selector syntax to find the #footer element and assign it to a variable of our choosing, this variable literally can be called anything as the task is only looking to see if the #footer element was selected.

Also anonymous functions can be assigned directly as arguments as jQuery will simply execute them if one is supplied.

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

Hope that helps.