From ca6b2ab4924fb7b138f7b7d9bf6e24bf886708e2 Mon Sep 17 00:00:00 2001 From: Kevin Boudloche Date: Tue, 21 May 2013 12:19:09 -0500 Subject: [PATCH] Improve error callback example for $.ajax The error handler includes two of the three parameters, but doesn't actually do anything with them. This is a very common place where new developers will get the "Sorry, there was a problem!" and not know how to go further to figure out what the problem was. Adding the logging may help improve that. --- page/ajax/jquery-ajax-methods.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/page/ajax/jquery-ajax-methods.md b/page/ajax/jquery-ajax-methods.md index 6f919f05..fb8fe6d3 100644 --- a/page/ajax/jquery-ajax-methods.md +++ b/page/ajax/jquery-ajax-methods.md @@ -52,8 +52,11 @@ $.ajax({ // code to run if the request fails; the raw request and // status codes are passed to the function - error: function( xhr, status ) { + error: function( xhr, status, errorThrown ) { alert( "Sorry, there was a problem!" ); + console.log( "Error: " + errorThrown ); + console.log( "Status: " + status ); + console.dir( xhr ); }, // code to run regardless of success or failure