Make sure prefilters have been called and transport has been selected before sending...
[jquery.git] / src / ajax.js
index 744476f..e910aa5 100644 (file)
@@ -10,7 +10,7 @@ var r20 = /%20/g,
        rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
        rselectTextarea = /^(?:select|textarea)/i,
        rts = /([?&])_=[^&]*/,
-       rurl = /^(\w+:)?\/\/([^\/?#]+)/,
+       rurl = /^(\w+:)?\/\/([^\/?#:]+)(?::(\d+))?/,
 
        // Slice function
        sliceFunc = Array.prototype.slice,
@@ -520,21 +520,26 @@ jQuery.extend({
                // Determine if a cross-domain request is in order
                var parts = rurl.exec( s.url.toLowerCase() ),
                        loc = location;
-               s.crossDomain = !!( parts && ( parts[ 1 ] && parts[ 1 ] != loc.protocol || parts[ 2 ] != loc.host ) );
+               s.crossDomain = !!(
+                               parts &&
+                               ( parts[ 1 ] && parts[ 1 ] != loc.protocol ||
+                                       parts[ 2 ] != loc.hostname ||
+                                       ( parts[ 3 ] || 80 ) != ( loc.port || 80 ) )
+               );
 
                // Convert data if not already a string
                if ( s.data && s.processData && typeof s.data != "string" ) {
                        s.data = jQuery.param( s.data , s.traditional );
                }
 
+               // Get transport
+               transport = jQuery.ajax.prefilter( s ).transport( s );
+
                // Watch for a new set of requests
                if ( s.global && jQuery.active++ === 0 ) {
                        jQuery.event.trigger( "ajaxStart" );
                }
 
-               // Get transport
-               transport = jQuery.ajax.prefilter( s ).transport( s );
-
                // If no transport, we auto-abort
                if ( ! transport ) {