Update CRM.status for compatability with native js promises
authorcolemanw <coleman@civicrm.org>
Sun, 20 Aug 2023 20:24:16 +0000 (16:24 -0400)
committercolemanw <coleman@civicrm.org>
Fri, 1 Sep 2023 18:08:36 +0000 (14:08 -0400)
Before: .done() method only works with jQuery object
After: .then() method works with both

js/Common.js

index 5521a863e718b6b453d5d50434c5f9631eb8780a..928972794bcb401eb4a4187aac158b9e2bb6d5d2 100644 (file)
@@ -1320,12 +1320,11 @@ if (!CRM.vars) CRM.vars = {};
       }
     }
     return (deferred || new $.Deferred())
-      .done(function(data) {
+      .then(function(data) {
         // If the server returns an error msg call the error handler
         var status = $.isPlainObject(data) && (data.is_error || data.status === 'error') ? 'error' : 'success';
         handle(status, data);
-      })
-      .fail(function(data) {
+      }, function(data) {
         handle('error', data);
       });
   };