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 Handle AJAX failures with jQuery

Jamie FitzHenry
Jamie FitzHenry
16,232 Points

AJAX Basics; jQuery and AJAX; Handle AJAX failures with JQuery; Challenge Task 2 out of 3.

I seem to be struggling with this one...

Challenge Task 2 of 3

jQuery's fail() method takes a callback function as an argument. The function is run when there's an error in the AJAX response. Pass an anonymous function as an argument to the method. Don't forget to set a parameter for that function. Use the name jqXHR for the parameter -- this parameter will hold a jQuery XHR object passed by the fail() method to the function.

Any help would be appreciated.

2 Answers

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,252 Points
$.get("missing.html", function(data) {

Try this. You need to add an anonymous function as a parameter to the fail method. Remember the fail method is chained directly to the end of get(). Hope this works. :)

Jamie FitzHenry
Jamie FitzHenry
16,232 Points

Thank you Jonathan, that did it!

I think I had been looking at it too long!!