[Jifty-commit] jifty branch, jifty_client, updated. ac745a0dec1500cb9c42e60cfb3332c39ab693e4

Jifty commits jifty-commit at lists.jifty.org
Fri Apr 30 06:46:38 EDT 2010


The branch, jifty_client has been updated
       via  ac745a0dec1500cb9c42e60cfb3332c39ab693e4 (commit)
      from  ce64b63b1733239349b68118af6154f99f030e75 (commit)

Summary of changes:
 share/web/static/js/jifty_client.js |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit ac745a0dec1500cb9c42e60cfb3332c39ab693e4
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Apr 30 18:46:37 2010 +0800

    Run the failure handler even if AJAX succeeds

diff --git a/share/web/static/js/jifty_client.js b/share/web/static/js/jifty_client.js
index d4646e6..aa01bb1 100644
--- a/share/web/static/js/jifty_client.js
+++ b/share/web/static/js/jifty_client.js
@@ -23,6 +23,17 @@ Class("JiftyClient", {
             );
         },
         runAction: function (name, params, onSuccess, onFailure) {
+            // if the action returns failure then we want to run the onFailure
+            // handler, even though the AJAX request was successful
+            var onAjaxSuccess = function (result) {
+                if (result.success) {
+                    onSuccess(result);
+                }
+                else {
+                    onFailure(result);
+                }
+            };
+
             jQuery.ajax({
                 url: "/=/action/" + name + ".json",
                 async: false,
@@ -30,7 +41,7 @@ Class("JiftyClient", {
                 dataType: "json",
                 type: 'POST',
                 error: onFailure,
-                success: onSuccess
+                success: onAjaxSuccess
             });
         }
     }

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list