[web/data] Support Deferred objects outside XHR
authorRémi Cardona <remi.cardona@logilab.fr>
Wed, 13 May 2015 15:58:21 +0200
changeset 10412 3540131a8405
parent 10411 4ee15441f2eb
child 10413 22a89d0f4143
[web/data] Support Deferred objects outside XHR JS tests actually use this. Related to #5533303.
web/data/cubicweb.ajax.js
--- a/web/data/cubicweb.ajax.js	Mon Jun 22 14:27:37 2015 +0200
+++ b/web/data/cubicweb.ajax.js	Wed May 13 15:58:21 2015 +0200
@@ -39,7 +39,7 @@
     },
 
     addCallback: function(callback) {
-        if ((this._req.readyState == 4) && this._result) {
+        if (this._req && (this._req.readyState == 4) && this._result) {
             var args = [this._result, this._req];
             jQuery.merge(args, cw.utils.sliceList(arguments, 1));
             callback.apply(null, args);
@@ -51,7 +51,7 @@
     },
 
     addErrback: function(callback) {
-        if (this._req.readyState == 4 && this._error) {
+        if (this._req && this._req.readyState == 4 && this._error) {
             callback.apply(null, [this._error, this._req]);
         }
         else {