jquery ajax: fixed #2865 and #2570. Not passing username to xml.open if it's null...
[jquery.git] / src / ajax.js
index 244397f..1dc7814 100644 (file)
@@ -141,6 +141,7 @@ jQuery.extend({
        },
 
        ajaxSettings: {
+               url: location.href,
                global: true,
                type: "GET",
                timeout: 0,
@@ -233,9 +234,13 @@ jQuery.extend({
                if ( s.global && ! jQuery.active++ )
                        jQuery.event.trigger( "ajaxStart" );
 
+               // Matches an absolute URL, and saves the domain
+               var remote = /^(?:\w+:)?\/\/([^\/?#]+)/;
+
                // 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"
+                               && remote.test(s.url) && remote.exec(s.url)[1] != location.host ){
                        var head = document.getElementsByTagName("head")[0];
                        var script = document.createElement("script");
                        script.src = s.url;
@@ -271,7 +276,11 @@ jQuery.extend({
                var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
 
                // Open the socket
-               xml.open(s.type, s.url, s.async, s.username, s.password);
+               // Passing null username, generates a login popup on Opera (#2865)
+               if( s.username )
+                       xml.open(s.type, s.url, s.async, s.username, s.password);
+               else
+                       xml.open(s.type, s.url, s.async);
 
                // Need an extra try/catch for cross domain requests in Firefox 3
                try {