]> source.dussan.org Git - jquery.git/commitdiff
jquery ajax: absolute urls were assumed to be cross domain. Closes #2816.
authorAriel Flesler <aflesler@gmail.com>
Tue, 13 May 2008 19:47:39 +0000 (19:47 +0000)
committerAriel Flesler <aflesler@gmail.com>
Tue, 13 May 2008 19:47:39 +0000 (19:47 +0000)
src/ajax.js

index 244397f4c9280c54cc10fb7b9c804c177b7b5d83..598232f68f19c5176cf7e1d6c969bdd6fb27a1e8 100644 (file)
@@ -235,7 +235,8 @@ jQuery.extend({
 
                // If we're requesting a remote document
                // and trying to load JSON or Script with a GET
-               if ( (!s.url.indexOf("http") || !s.url.indexOf("//")) && s.dataType == "script" && s.type.toLowerCase() == "get" ) {
+               if ( s.dataType == "script" && s.type.toLowerCase() == "get"
+                               && jQuery.ajax.re.test(s.url) && jQuery.ajax.re.exec(s.url)[1] != location.host ){
                        var head = document.getElementsByTagName("head")[0];
                        var script = document.createElement("script");
                        script.src = s.url;
@@ -499,3 +500,6 @@ jQuery.extend({
        }
 
 });
+
+// Matches an absolute URL, and saves the domain
+jQuery.ajax.re = /^(?:\w+:)?\/\/([^\/?#]+)/;