Skip to content

Commit

Permalink
Ajax in 1.11 passed along the response text and xml to the onComplete…
Browse files Browse the repository at this point in the history
… even when there was a failure
  • Loading branch information
anutron committed Apr 15, 2010
1 parent b030032 commit 4c92f79
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Request/Request.js
@@ -1,3 +1,29 @@
Request.implement({
//1.11 passed along the response text and xml to onComplete
onStateChange: function(){
if (this.xhr.readyState != 4 || !this.running) return;
this.running = false;
this.status = 0;
$try(function(){
this.status = this.xhr.status;
}.bind(this));
this.xhr.onreadystatechange = $empty;
this.response = {text: this.xhr.responseText, xml: this.xhr.responseXML};
if (this.options.isSuccess.call(this, this.status)) this.success(this.response.text, this.response.xml);
else this.failure(this.response.text, this.response.xml);
},

failure: function(){
this.onFailure.apply(this, arguments);
},

onFailure: function(){
MooTools.upgradeLog('1.1 > 1.2: Note that onComplete does not receive arguments in 1.2.');
this.fireEvent('complete', arguments).fireEvent('failure', this.xhr);
}

});

var XHR = new Class({

Extends: Request,
Expand Down

0 comments on commit 4c92f79

Please sign in to comment.