1// Ajax mode: abort 2// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]}); 3// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort() 4 5var pendingRequests = {}, 6 ajax; 7 8// Use a prefilter if available (1.5+) 9if ( $.ajaxPrefilter ) { 10 $.ajaxPrefilter( function( settings, _, xhr ) { 11 var port = settings.port; 12 if ( settings.mode === "abort" ) { 13 if ( pendingRequests[ port ] ) { 14 pendingRequests[ port ].abort(); 15 } 16 pendingRequests[ port ] = xhr; 17 } 18 } ); 19} else { 20 21 // Proxy ajax 22 ajax = $.ajax; 23 $.ajax = function( settings ) { 24 var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode, 25 port = ( "port" in settings ? settings : $.ajaxSettings ).port; 26 if ( mode === "abort" ) { 27 if ( pendingRequests[ port ] ) { 28 pendingRequests[ port ].abort(); 29 } 30 pendingRequests[ port ] = ajax.apply( this, arguments ); 31 return pendingRequests[ port ]; 32 } 33 return ajax.apply( this, arguments ); 34 }; 35}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.