aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--polldance.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/polldance.js b/polldance.js
index 2401074..66c76c1 100644
--- a/polldance.js
+++ b/polldance.js
@@ -42,6 +42,13 @@
var corsAvailable = "withCredentials" in new XMLHttpRequest();
+ function sameOrigin(url) {
+ var loc = window.location;
+ var a = document.createElement('a');
+ a.href = url;
+ return !a.hostname || (a.hostname == loc.hostname && a.port == loc.port && a.protocol == loc.protocol);
+ }
+
var Events = function () {
this._events = {};
};
@@ -157,7 +164,7 @@
++self._tries;
if (self.transport == TransportTypes.Auto) {
- if (corsAvailable) {
+ if (corsAvailable || sameOrigin(self._url)) {
self.transport = TransportTypes.Xhr;
} else {
self.transport = TransportTypes.Jsonp;