mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Fixes cross domain XHR on IE8/9
This commit is contained in:
@@ -64,7 +64,7 @@
|
||||
|
||||
function stateChange () {
|
||||
if (this.readyState == 4) {
|
||||
this.onreadystatechange = this.onload = empty;
|
||||
this.onreadystatechange = empty;
|
||||
|
||||
if (this.status == 200) {
|
||||
self.onData(this.responseText);
|
||||
@@ -73,13 +73,21 @@
|
||||
self.onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function onload () {
|
||||
this.onload = empty;
|
||||
self.onData(this.responseText);
|
||||
self.get();
|
||||
};
|
||||
|
||||
this.xhr = this.request();
|
||||
|
||||
if (window.XDomainRequest && this.xhr instanceof XDomainRequest) {
|
||||
this.xhr.onload = stateChange;
|
||||
this.xhr.onerror = function (e) { self.onError(e); };
|
||||
this.xhr.onload = onload;
|
||||
this.xhr.onerror = function (e) {
|
||||
self.onError(e);
|
||||
};
|
||||
} else {
|
||||
this.xhr.onreadystatechange = stateChange;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
|
||||
function stateChange () {
|
||||
if (this.readyState == 4) {
|
||||
this.onreadystatechange = this.onload = empty;
|
||||
this.onreadystatechange = empty;
|
||||
self.posting = false;
|
||||
|
||||
if (this.status == 200){
|
||||
@@ -114,10 +114,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
function onload () {
|
||||
this.onload = empty;
|
||||
self.posting = false;
|
||||
self.checkSend();
|
||||
};
|
||||
|
||||
this.sendXHR = this.request('POST');
|
||||
|
||||
if (window.XDomainRequest && this.xhr instanceof XDomainRequest) {
|
||||
this.sendXHR.onload = stateChange;
|
||||
this.sendXHR.onload = onload;
|
||||
this.sendXHR.onerror = function (e) {
|
||||
self.onError(e);
|
||||
};
|
||||
} else {
|
||||
this.sendXHR.onreadystatechange = stateChange;
|
||||
}
|
||||
@@ -171,7 +180,9 @@
|
||||
req.setRequestHeader('Content-type', 'text/plain');
|
||||
} else {
|
||||
// XDomainRequest
|
||||
req.contentType = 'text/plain';
|
||||
try {
|
||||
req.contentType = 'text/plain';
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user