Skip to content

Commit

Permalink
Fixed async bug in xhr
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Robinson committed May 18, 2009
1 parent c721919 commit f1baa35
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/browser/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,12 @@ XMLHttpRequest.prototype.send = function(data)

this.responseText = input.read().decodeToString("UTF-8"); // FIXME: don't assume UTF-8?
}
system.log.debug("xhr response: " + this.url + " (length="+this.responseText.length+")");
system.log.debug("xhr response: " + this._url + " (status="+this.status+" length="+this.responseText.length+")");
}
catch (e) {
print(e);
this.status = 500;
this.responseText = "";
system.log.debug("xhr exception: " + this.url + " ("+e+")");
system.log.warn("xhr exception: " + this.url + " ("+e+")");
}

this.responseXML = null;
Expand All @@ -337,8 +336,9 @@ XMLHttpRequest.prototype.send = function(data)
// FIXME: this is very very wrong
this.readyState = DONE;
if (this.onreadystatechange) {
if (this.async)
require("./timeout").setTimeout(function() { this.onreadystatechange() }, 0); // FIXME
var that = this;
if (this._async)
require("./timeout").setTimeout(function() { that.onreadystatechange() }, 0); // FIXME
else
this.onreadystatechange();
}
Expand Down

0 comments on commit f1baa35

Please sign in to comment.