Properly plug the error callback.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 26 Feb 2011 11:04:23 +0000 (12:04 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 26 Feb 2011 11:07:01 +0000 (12:07 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
htdocs/javascript/core.js

index eb0893b..3a79984 100644 (file)
     };
 
     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);
     };