diff --git a/Promises.js b/Promises.js index 9519255..ee396c6 100644 --- a/Promises.js +++ b/Promises.js @@ -116,19 +116,34 @@ var Promise = new Class({ initReq: function(req) { this.__req = req; + req.addEvent('onSuccess', function(responseText) { this.setValue(this.applyOps(JSON.decode(responseText).data)); }.bind(this)); req.addEvent('onFailure', function(responseText) { this.fireEvent('error', this); }.bind(this)); - if(!this.options.lazy) req.send(); + + if(!this.options.lazy) this.send(); + }, + + + send: function() + { + if(this.__req.__json) + { + this.__req.send(JSON.encode(this.__req.__json)); + } + else + { + this.__req.send(); + } }, realize: function() { - if(this.__req) this.__req.send(); + if(this.__req) this.send(); },