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
MOD
Jonathan Grieve
Treehouse Moderator 83,943 Points
$.get("missing.html", function(data) {
  $("#footer").html(data);
}).fail(function(jqHR){});

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!!