web/data/cubicweb.ajax.js
branchstable
changeset 6552 256725d4e3ec
parent 6215 759cf097f5aa
child 6556 64b39aa0b047
equal deleted inserted replaced
6541:9c3821885443 6552:256725d4e3ec
    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;
   330             data: form,
   328             data: form,
   331             async: false
   329             async: false
   332         });
   330         });
   333         // check result.responseText instead of result to avoid error encountered with IE
   331         // check result.responseText instead of result to avoid error encountered with IE
   334         if (result.responseText) {
   332         if (result.responseText) {
   335             // XXX no good reason to force json here, 
   333             // XXX no good reason to force json here,
   336             // it should depends on request content-type
   334             // it should depends on request content-type
   337             result = cw.evalJSON(result.responseText);
   335             result = cw.evalJSON(result.responseText);
   338         }
   336         }
   339         return result;
   337         return result;
   340     }
   338     }