From aa2ac7586d7bb1e1479e65a0adef781395fdc57c Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sat, 26 Feb 2011 12:04:23 +0100 Subject: [PATCH] Properly plug the error callback. Signed-off-by: Florent Bruneau --- htdocs/javascript/core.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/htdocs/javascript/core.js b/htdocs/javascript/core.js index eb0893b..3a79984 100644 --- a/htdocs/javascript/core.js +++ b/htdocs/javascript/core.js @@ -39,21 +39,19 @@ }; var ajaxParams = function(onSuccess, onError, extraParameters) { - return $.extend({ - success: function(data, textStatus, xhr) { - if (textStatus === 'success') { - if (onSuccess) { - onSuccess(data, textStatus, xhr); - } - } else if (textStatus === 'error') { - if (onError) { - onError(data, textStatus, xhr); - } else { - alert("Une error s'est produite lors du traitement de la requête.\n" - + "Ta session a peut-être expiré"); - } - } + function errorHandler() + { + if (onError) { + return onError.apply(this, arguments); + } else { + alert("Une error s'est produite lors du traitement de la requête.\n" + + "Ta session a peut-être expiré"); } + } + + return $.extend({ + success: onSuccess, + error: errorHandler }, extraParameters); }; -- 2.1.4