changeset 5538:35943bda15b8

js: add failure callback to ajaxGET Like ajaxPOST.
author Mads Kiilerich <madski@unity3d.com>
date Thu, 08 Oct 2015 23:27:41 +0200
parents f38b50f8a6a6
children 87285c5007fb
files kallithea/public/js/base.js
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/js/base.js	Thu Oct 08 23:25:21 2015 +0200
+++ b/kallithea/public/js/base.js	Thu Oct 08 23:27:41 2015 +0200
@@ -377,15 +377,16 @@
         ;
 };
 
-var ajaxGET = function(url,success) {
+var ajaxGET = function(url, success, failure) {
+    if(failure === undefined) {
+        failure = function(jqXHR, textStatus, errorThrown) {
+                if (textStatus != "abort")
+                    alert("Ajax GET error: " + textStatus);
+            };
+    }
     return $.ajax({url: url, headers: {'X-PARTIAL-XHR': '1'}, cache: false})
         .done(success)
-        .fail(function(jqXHR, textStatus, errorThrown) {
-                if (textStatus == "abort")
-                    return;
-                alert("Ajax GET error: " + textStatus);
-        })
-        ;
+        .fail(failure);
 };
 
 var ajaxPOST = function(url, postData, success, failure) {