@@ -415,6 +415,9 @@ jQuery.extend( {
415415 // Loop variable
416416 i ,
417417
418+ // uncached part of the url
419+ uncached ,
420+
418421 // Create the final options object
419422 s = jQuery . ajaxSetup ( { } , options ) ,
420423
@@ -516,11 +519,10 @@ jQuery.extend( {
516519 // Attach deferreds
517520 deferred . promise ( jqXHR ) ;
518521
519- // Remove hash character (#7531: and string promotion)
520522 // Add protocol if not provided (prefilters might expect it)
521523 // Handle falsy url in the settings object (#10093: consistency with old signature)
522524 // We also use the url parameter if available
523- s . url = ( ( url || s . url || location . href ) + "" ) . replace ( rhash , "" )
525+ s . url = ( ( url || s . url || location . href ) + "" )
524526 . replace ( rprotocol , location . protocol + "//" ) ;
525527
526528 // Alias method option to type as per ticket #12004
@@ -581,30 +583,32 @@ jQuery.extend( {
581583
582584 // Save the URL in case we're toying with the If-Modified-Since
583585 // and/or If-None-Match header later on
584- cacheURL = s . url ;
586+ // Remove hash to simplify url manipulation
587+ cacheURL = s . url . replace ( rhash , "" ) ;
585588
586589 // More options handling for requests with no content
587590 if ( ! s . hasContent ) {
588591
592+ // Remember the hash so we can put it back
593+ uncached = s . url . slice ( cacheURL . length ) ;
594+
589595 // If data is available, append data to url
590596 if ( s . data ) {
591- cacheURL = ( s . url += ( rquery . test ( cacheURL ) ? "&" : "?" ) + s . data ) ;
597+ cacheURL += ( rquery . test ( cacheURL ) ? "&" : "?" ) + s . data ;
592598
593599 // #9682: remove data so that it's not used in an eventual retry
594600 delete s . data ;
595601 }
596602
597- // Add anti-cache in url if needed
603+ // Add anti-cache in uncached url if needed
598604 if ( s . cache === false ) {
599- s . url = rts . test ( cacheURL ) ?
600-
601- // If there is already a '_' parameter, set its value
602- cacheURL . replace ( rts , "$1_=" + nonce ++ ) :
603-
604- // Otherwise add one to the end
605- cacheURL + ( rquery . test ( cacheURL ) ? "&" : "?" ) + "_=" + nonce ++ ;
605+ cacheURL = cacheURL . replace ( rts , "" ) ;
606+ uncached = ( rquery . test ( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce ++ ) + uncached ;
606607 }
607608
609+ // Put hash and anti-cache on the URL that will be requested (gh-1732)
610+ s . url = cacheURL + uncached ;
611+
608612 // Change '%20' to '+' if this is encoded form body content (gh-2658)
609613 } else if ( s . data && s . processData &&
610614 ( s . contentType || "" ) . indexOf ( "application/x-www-form-urlencoded" ) === 0 ) {
0 commit comments