May 2017
Intermediate to advanced
448 pages
10h 10m
English
The $.ajaxPrefilter() function can add prefilters, which are callback functions that allow us to manipulate requests before they are sent. Prefilters are invoked before $.ajax() changes or uses any of its options, so they are a good place to change the options or act on new custom options.
Prefilters can also manipulate the data type of the request by simply returning the name of the new data type to use. In our YAML example, we specified yaml as the data type because we didn't want to rely on the server supplying the correct MIME type for the response. We could, though, provide a prefilter that ensures the data type is yaml if the corresponding file extension ( .yml) is in the URL we request:
$.ajaxPrefilter(({ url ...Read now
Unlock full access