diff --git a/lib/transports/polling-xhr.js b/lib/transports/polling-xhr.js index de68fd8b..7a8a34bf 100644 --- a/lib/transports/polling-xhr.js +++ b/lib/transports/polling-xhr.js @@ -141,8 +141,10 @@ util.inherits(Request, EventEmitter); */ Request.prototype.create = function () { - var xhr = this.xhr = util.request(this.xd); - this.xhr.open(this.method, this.uri, this.async); + var xhr = this.xhr = util.request(this.xd) + , self = this + + xhr.open(this.method, this.uri, this.async); if ('POST' == this.method) { try { @@ -156,9 +158,9 @@ Request.prototype.create = function () { } catch (e) {} } - if (this.xd && global.XDomainRequest && this.xhr instanceof XDomainRequest) { - this.xhr.onerror = function () { - self.onError(); + if (this.xd && global.XDomainRequest && xhr instanceof XDomainRequest) { + xhr.onerror = function (e) { + self.onError(e); }; this.xhr.onload = function () { self.onData(xhr.responseText);