X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax.js;h=d570fcccb8173d02e34ddf59e118fff4ebdc3ec0;hb=4e86766d54a71263f8e7cbf2957405e12d9b8b36;hp=744476f1a399f5d77bac0290861d58f21bc1b228;hpb=d515068ee807efef29b6c8406171be4725d7154f;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index 744476f..d570fcc 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -10,7 +10,8 @@ var r20 = /%20/g, rscript = /)<[^<]*)*<\/script>/gi, rselectTextarea = /^(?:select|textarea)/i, rts = /([?&])_=[^&]*/, - rurl = /^(\w+:)?\/\/([^\/?#]+)/, + rurl = /^(\w+:)?\/\/([^\/?#:]+)(?::(\d+))?/, + rCRLF = /\r?\n/g, // Slice function sliceFunc = Array.prototype.slice, @@ -107,9 +108,9 @@ jQuery.fn.extend({ null : jQuery.isArray(val) ? jQuery.map( val, function(val, i){ - return {name: elem.name, value: val.replace(/\r?\n/g, "\r\n")}; + return { name: elem.name, value: val.replace(rCRLF, "\r\n") }; }) : - {name: elem.name, value: val.replace(/\r?\n/g, "\r\n")}; + { name: elem.name, value: val.replace(rCRLF, "\r\n") }; }).get(); } }); @@ -520,21 +521,29 @@ 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 ) ); + + if ( ! s.crossDomain ) { + 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 , options ).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 ) {