Skip to content

Commit

Permalink
fix callbacks calls on crossdomain requests for IE
Browse files Browse the repository at this point in the history
  • Loading branch information
wandenberg committed Dec 30, 2014
1 parent d512497 commit 35c7450
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions misc/js/pushstream.js
Expand Up @@ -237,17 +237,29 @@ Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider

settings.xhr = xhr;

xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
Ajax.clear(settings);
if (window.XDomainRequest && (xhr instanceof window.XDomainRequest)) {
xhr.onload = function () {
if (settings.afterReceive) { settings.afterReceive(xhr); }
if(xhr.status === 200) {
if (settings.success) { settings.success(xhr.responseText); }
} else {
if (settings.error) { settings.error(xhr.status); }
if (settings.success) { settings.success(xhr.responseText); }
};

xhr.onerror = xhr.ontimeout = function () {
if (settings.afterReceive) { settings.afterReceive(xhr); }
if (settings.error) { settings.error(xhr.status); }
};
} else {
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
Ajax.clear(settings);
if (settings.afterReceive) { settings.afterReceive(xhr); }
if(xhr.status === 200) {
if (settings.success) { settings.success(xhr.responseText); }
} else {
if (settings.error) { settings.error(xhr.status); }
}
}
}
};
};
}

if (settings.beforeOpen) { settings.beforeOpen(xhr); }

Expand Down

0 comments on commit 35c7450

Please sign in to comment.