web/data/cubicweb.ajax.js
changeset 6565 e89de028d004
parent 6555 f8b36b1e98bf
parent 6560 48ba5069e051
child 6645 179eb6131e92
equal deleted inserted replaced
6564:ff9f7c566464 6565:e89de028d004
    34         this._result = null;
    34         this._result = null;
    35         this._error = null;
    35         this._error = null;
    36     },
    36     },
    37 
    37 
    38     addCallback: function(callback) {
    38     addCallback: function(callback) {
    39         if (this._req.readyState == 4) {
    39         if ((this._req.readyState == 4) && this._result) {
    40             if (this._result) {
    40             var args = [this._result, this._req];
    41                 var args = [this._result, this._req];
    41             jQuery.merge(args, cw.utils.sliceList(arguments, 1));
    42                 jQuery.merge(args, cw.utils.sliceList(arguments, 1));
    42             callback.apply(null, args);
    43                 callback.apply(null, args);
       
    44             }
       
    45         }
    43         }
    46         else {
    44         else {
    47             this._onSuccess.push([callback, cw.utils.sliceList(arguments, 1)]);
    45             this._onSuccess.push([callback, cw.utils.sliceList(arguments, 1)]);
    48         }
    46         }
    49         return this;
    47         return this;
    50     },
    48     },
    51 
    49 
    52     addErrback: function(callback) {
    50     addErrback: function(callback) {
    53         if (this._req.readyState == 4) {
    51         if (this._req.readyState == 4 && this._error) {
    54             if (this._error) {
    52             callback.apply(null, [this._error, this._req]);
    55                 callback.apply(null, [this._error, this._req]);
       
    56             }
       
    57         }
    53         }
    58         else {
    54         else {
    59             this._onFailure.push([callback, cw.utils.sliceList(arguments, 1)]);
    55             this._onFailure.push([callback, cw.utils.sliceList(arguments, 1)]);
    60         }
    56         }
    61         return this;
    57         return this;