Skip to content

Commit

Permalink
support sending JSON data via a Promise.
Browse files Browse the repository at this point in the history
  • Loading branch information
swannodette committed Jul 21, 2009
1 parent 73a3cbc commit 6fc314a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Promises.js
Expand Up @@ -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();
},


Expand Down

0 comments on commit 6fc314a

Please sign in to comment.