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 trialUnsubscribed User
7,273 PointsTask for jQuery AJAX fail() method is refusing to evaluate my answer, but jqXHR object is being accessed. What now?
Hi everyone!
I'm stuck on the final stage of a Challenge Task on jQuery's AJAX .fail() method. The task calls for us to alert the user with the jqXHR object's statusText property. I've added the code and the alert box is popping up with the 'Not Found' status text, but Treehouse's editor is refusing to evaluate my code.
Where am I going wrong here?
Thanks for your help in advance!
George
$.get("missing.html", function(data) {
$("#footer").html(data);
}).fail( function( jqXHR ) {
alert( jqXHR.statusText );
});
<!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
jcorum
71,830 PointsYours:
$.get("missing.html", function(data) {
$("#footer").html(data);
}).fail( function( jqXHR ) {
alert( jqXHR.statusText );
});
One that works:
$.get("missing.html", function(data) {
$("#footer").html(data);
}).fail(function(jqXHR) {
alert(jqXHR.statusText)
});
What's the difference? I pasted yours into the Challenge and removed the spaces you had around the anonymous function's parameter and the alert function's parameter! Wow! The editor is a bit picky.
Unsubscribed User
7,273 PointsUnsubscribed User
7,273 PointsI tried that after getting a bit frustrated, and you're right - it did work :) I'm a bit disappointed that the editor is so fussy when it comes to the user's own syntactical styling.
Thanks for the input!