Originally from: http://www.runoob.com/jquery/ajax-ajaxsetup.html
Example
Set the default URL and success function for all AJAX requests: $ ("button"). Click (function () {
$.ajaxsetup ({url: "Demo_ajax_load.txt", success:function (Result) {
$ ("div"). html (result);}});
$.ajax ();
});
Try» Definitions and usage
The Ajaxsetup () method sets the default value for future AJAX requests. Syntax $.ajaxsetup ({name:value, Name:value, ...})
This parameter specifies the setting for AJAX requests with one or more name/value pairs.
The possible names/values are listed in the following table:
name |
Value/Description |
Async |
A Boolean value that indicates whether the request is processed asynchronously. The default is true. |
Beforesend (XHR) |
The function that is run before the request is sent. |
Cache |
A Boolean value that indicates whether the browser caches the requested page. The default is true. |
Complete (xhr,status) |
A function that runs when the request completes (called after the request succeeds or fails, that is, after the success and the error function). |
ContentType |
The type of content to use when sending data to the server. The default is: "Application/x-www-form-urlencoded". |
Context |
Specifies the "This" value for all AJAX-related callback functions. |
Data |
Specifies the data to be sent to the server. |
Datafilter (Data,type) |
A function for handling XMLHttpRequest raw response data. |
DataType |
The data type of the expected server response. |
Error (XHR,STATUS,ERROR) |
The function to run if the request fails. |
Global |
A Boolean value that specifies whether the global AJAX event handler is triggered for the request. The default is true. |
Ifmodified |
Boolean value that specifies whether the request succeeds only if the response has changed since the last request. The default is False. |
Jsonp |
A string that overrides the callback function in a JSONP. |
Jsonpcallback |
Specifies the name of the callback function in a JSONP. |
Password |
Specifies the password that is used in HTTP access authentication requests. |
ProcessData |
A Boolean value that specifies whether the data sent through the request is converted to a query string. The default is true. |
Scriptcharset |
Specifies the requested character set. |
Success (RESULT,STATUS,XHR) |
The function that is run when the request succeeds. |
Timeout |
Sets the local request time-out (in milliseconds). |
Traditional |
A Boolean value that specifies whether to use the traditional style of parameter serialization. |
Type |
Specifies the type of request (GET or POST). |
Url |
Specifies the URL to send the request to. The default is the current page. |
Username |
Specifies the user name to use in HTTP access authentication requests. |
Xhr |
The function used to create the XMLHttpRequest object. |