Is it possible to g开发者_JAVA技巧et all the defaults that are associcate with the $.ajax
function.
So it would return something like this:
{
global:true,
headers:{},
ifModified:false,
type:"GET",
url:"the current page url",
etc....
}
From looking at the source code, I believe the (current) defaults are found in jQuery.ajaxSettings
, of course also available as $.ajaxSettings
. So if you haven't changed them, you should be able to get them from there.
Note that if you have changed them, for example using the $.ajaxSetup
utility method, you'll get the new defaults you created, not the inherent ones from the jQuery library.
Also looking at the source code, it seems the defaults are the following:
ajaxSettings: {
url: ajaxLocation,
isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
global: true,
type: "GET",
contentType: "application/x-www-form-urlencoded",
processData: true,
async: true,
/*
timeout: 0,
data: null,
dataType: null,
username: null,
password: null,
cache: null,
traditional: false,
headers: {},
*/
accepts: {
xml: "application/xml, text/xml",
html: "text/html",
text: "text/plain",
json: "application/json, text/javascript",
"*": "*/*"
},
contents: {
xml: /xml/,
html: /html/,
json: /json/
},
responseFields: {
xml: "responseXML",
text: "responseText"
},
// List of data converters
// 1) key format is "source_type destination_type" (a single space in-between)
// 2) the catchall symbol "*" can be used for source_type
converters: {
// Convert anything to text
"* text": window.String,
// Text to html (true = no transformation)
"text html": true,
// Evaluate text as a json expression
"text json": jQuery.parseJSON,
// Parse text as xml
"text xml": jQuery.parseXML
}
},
They are listed in the jQuery docs:
http://api.jquery.com/jQuery.ajax/
精彩评论