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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Hamed Ali](https://uploads.teamtreehouse.com/production/profile-photos/7898642/micro_Hamed_Ali_Jul-30-2013_95p_blured_cropped_smallersize.jpg)
Hamed Ali
5,626 PointsSimple question: How to chain the .fail() method to the $.get() method ?
Does someone know how to chain the .fail() method to the $.get() method ? I tried chaining it right at the end, immediately after the .get and also right after the function. None of these worked.
$.get("missing.html", function(data) {
$("#footer").html(data)();
}.fail);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>AJAX with JavaScript</title>
</head>
<body>
<div id="main">
<h1>AJAX with jQuery</h1>
</div>
<div id="footer"></div>
<script src="jquery.js"></script>
<script src="app.js"></script>
</body>
</html>
1 Answer
![Hamed Ali](https://uploads.teamtreehouse.com/production/profile-photos/7898642/micro_Hamed_Ali_Jul-30-2013_95p_blured_cropped_smallersize.jpg)
Hamed Ali
5,626 PointsWhat you are saying is actually false Steven.
You can chain these (as per challenge requirements) and here is the correct solution:
$.get("missing.html", function(data) { $("#footer").html(data); }).fail(function(jqXHR) { alert(jqXHR.statusText) });
Steven Parker
230,688 PointsSteven Parker
230,688 PointsI forgot to check the challenge itself (I must've been in a hurry!), and was trusting Hamed's description and the jQuery documentation. It says $get() returns a jqXHR object, and .fail() is a method of (and returns) a Deferred object. Further, it says "The Deferred object is chainable, similar to the way a jQuery object is chainable, but it has its own methods."
Check the jQuery documentation for yourself and let me know if I missed something.
But good job finding the solution.![:+1: :+1:](https://image-proxy-cdn.teamtreehouse.com/6d8de85e38fee3161a0f29fbc06cd3701ecdafed/68747470733a2f2f7374617469632e7465616d74726565686f7573652e636f6d2f696d616765732f656d6f6a692f756e69636f64652f31663434642e706e67)