Is there any way to get $ .ajax default object

Is it possible to get all the default values ​​that are associated with the $.ajax function.

So, it will return something like this:

 { global:true, headers:{}, ifModified:false, type:"GET", url:"the current page url", etc.... } 
+6
source share
2 answers

From a look at the source code , I believe that the current default values ​​found in jQuery.ajaxSettings are of course also available as $.ajaxSettings . Therefore, if you have not changed them, you can get them from there.

Please note that if you change them, for example, using the $.ajaxSetup utility method, you will get the new default values ​​that you created, and not integral from the jQuery library.

Also, looking at the source code, it seems that the default values ​​are as follows:

 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 } }, 
+8
source

These are listed in jQuery docs:

http://api.jquery.com/jQuery.ajax/

0
source

Source: https://habr.com/ru/post/893806/


All Articles