Use ajaxSetup()
the method to set some of the global option values for the AJAX request, and after the setup is complete, the subsequent AJAX requests will not need to add these option values, which are called in the following format:
jQuery.ajaxSetup([options])
Or$.ajaxSetup([options])
The optional options parameter is an object that sets the global option value for an AJAX request.
For example, first call the ajaxSetup()
method to set the global Ajax option value, then click two buttons, respectively, using the ajax()
method to request different server data, and display the data content on the page, as shown in:
Effects displayed in the browser:
As you can see, when you use ajaxSetup()
the method to set some of the global configuration options for AJAX requests, you only need to set the URL address when you call the AJAX Request Server TXT file two times.
26. Set global AJAX default options using the Ajaxsetup () method