[js/ajax] fix deferred race condition stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 19 Oct 2010 14:07:52 +0200
branchstable
changeset 6552 256725d4e3ec
parent 6541 9c3821885443
child 6556 64b39aa0b047
[js/ajax] fix deferred race condition
web/data/cubicweb.ajax.js
--- a/web/data/cubicweb.ajax.js	Tue Oct 19 10:04:50 2010 +0200
+++ b/web/data/cubicweb.ajax.js	Tue Oct 19 14:07:52 2010 +0200
@@ -36,12 +36,10 @@
     },
 
     addCallback: function(callback) {
-        if (this._req.readyState == 4) {
-            if (this._result) {
-                var args = [this._result, this._req];
-                jQuery.merge(args, cw.utils.sliceList(arguments, 1));
-                callback.apply(null, args);
-            }
+        if ((this._req.readyState == 4) & this._result) {
+            var args = [this._result, this._req];
+            jQuery.merge(args, cw.utils.sliceList(arguments, 1));
+            callback.apply(null, args);
         }
         else {
             this._onSuccess.push([callback, cw.utils.sliceList(arguments, 1)]);
@@ -332,7 +330,7 @@
         });
         // check result.responseText instead of result to avoid error encountered with IE
         if (result.responseText) {
-            // XXX no good reason to force json here, 
+            // XXX no good reason to force json here,
             // it should depends on request content-type
             result = cw.evalJSON(result.responseText);
         }