X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fajax%2Fxhr.js;h=5dbc33d3fd7e7751a1ea15628993f2f2ac1c63d8;hb=735a949a0649f0299e8e4d87b259290970a68ddf;hp=c48ac901fac737cfc4af9b4d72683ee9a004fbbb;hpb=3a1d7a3c7c5349021f6dae979ab9b8609ae8f105;p=jquery.git diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js index c48ac90..5dbc33d 100644 --- a/src/ajax/xhr.js +++ b/src/ajax/xhr.js @@ -26,7 +26,7 @@ function createStandardXHR() { function createActiveXHR() { try { - return new window.ActiveXObject("Microsoft.XMLHTTP"); + return new window.ActiveXObject( "Microsoft.XMLHTTP" ); } catch( e ) {} } @@ -92,12 +92,13 @@ if ( jQuery.support.ajax ) { xhr.overrideMimeType( s.mimeType ); } - // Requested-With header - // Not set for crossDomain requests with no content - // (see why at http://trac.dojotoolkit.org/ticket/9486) - // Won't change header if already provided - if ( !( s.crossDomain && !s.hasContent ) && !headers["x-requested-with"] ) { - headers[ "x-requested-with" ] = "XMLHttpRequest"; + // X-Requested-With header + // For cross-domain requests, seeing as conditions for a preflight are + // akin to a jigsaw puzzle, we simply never set it to be sure. + // (it can always be set on a per-request basis or even using ajaxSetup) + // For same-domain requests, won't change header if already provided. + if ( !s.crossDomain && !headers["X-Requested-With"] ) { + headers[ "X-Requested-With" ] = "XMLHttpRequest"; } // Need an extra try/catch for cross domain requests in Firefox 3 @@ -166,14 +167,16 @@ if ( jQuery.support.ajax ) { } // Filter status for non standard behaviors - status = - // If the request is local and we have data: assume a success - // (success with no data won't get notified, that's the best we - // can do given current implementations) - !status && s.isLocal ? - ( responses.text ? 200 : 404 ) : - // IE - #1450: sometimes returns 1223 when it should be 204 - ( status === 1223 ? 204 : status ); + + // If the request is local and we have data: assume a success + // (success with no data won't get notified, that's the best we + // can do given current implementations) + if ( !status && s.isLocal && !s.crossDomain ) { + status = responses.text ? 200 : 404; + // IE - #1450: sometimes returns 1223 when it should be 204 + } else if ( status === 1223 ) { + status = 204; + } } } } catch( firefoxAccessException ) {