jQuery Tutorial Tutorials - jQuery.ajaxPrefilter()

jQuery jQuery.ajaxPrefilter()

The jQuery.ajaxPrefilter() method in jQuery is used to customize Ajax options before each request is sent and before they are processed by $.ajax().

jQuery jQuery.ajaxPrefilter() syntax

jQuery.ajaxPrefilter( [dataTypes ], handler )

dataTypes is an optional string containing one or more space-separated dataTypes.
handler to set default values

jQuery jQuery.ajaxPrefilter() example

example

automatically abort a request to the same URL if the custom abortOnRetry option is set to true

var currentRequests = {};
 
$.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
  if ( options.abortOnRetry ) {
    if ( currentRequests[ options.url ] ) {
      currentRequests[ options.url ].abort();
    }
    currentRequests[ options.url ] = jqXHR;
  }
});
Date:2019-08-30 02:53:39 From:www.Lautturi.com author:Lautturi