src/js/data.js
branchpopcorn-port
changeset 452 35495f156c41
parent 291 e942a49240f4
child 453 8568e47379a2
--- a/src/js/data.js	Tue Dec 13 10:27:23 2011 +0100
+++ b/src/js/data.js	Tue Dec 13 15:14:15 2011 +0100
@@ -35,7 +35,17 @@
                   }
       };
       
-      IriSP.jQuery.get(url, IriSP.wrap(this, func));                                
+      /* automagically choose between json and jsonp */
+      if (url.indexOf(document.location.hostname) === -1 &&
+          url[0] !== '/' /* not a relative url */ ) {
+        // we contacting a foreign domain, use JSONP
+
+        IriSP.jQuery.get(url, {}, IriSP.wrap(this, func), "jsonp");
+      } else {
+
+        // otherwise, hey, whatever rows your boat
+        IriSP.jQuery.get(url, IriSP.wrap(this, func));
+      }
     
     } else {
       /* simply push the callback - it'll get called when the ressource