control-freak-ide/Control-Freak-Documentation/jQuery/docs/entries/jQuery.ajaxSetup.json
plastic-hub-dev-node-saturn 538369cff7 latest
2021-05-12 18:35:18 +02:00

1 line
2.5 KiB
JSON

{"name":"jQuery.ajaxSetup","type":"method","title":"jQuery.ajaxSetup()","deprecated":null,"removed":null,"desc":"Set default values for future Ajax requests. Its use is not recommended.","categories":["ajax/low-level-interface","version/1.1"],"entries":[{"return":"","signatures":{"added":"1.1","argument":{"desc":"A set of key/value pairs that configure the default Ajax request. All options are optional. ","name":"options","type":"PlainObject"}},"examples":{"desc":"Sets the defaults for Ajax requests to the url \"/xmlhttp/\", disables global handlers and uses POST instead of GET. The following Ajax requests then sends some data without having to set anything else.","code":"\n$.ajaxSetup({\n url: \"/xmlhttp/\",\n global: false,\n type: \"POST\"\n});\n$.ajax({ data: myData });\n"},"longdesc":"\n <p>For details on the settings available for <code>$.ajaxSetup()</code>, see <code><a href=\"/jQuery.ajax/\">$.ajax()</a></code>. </p>\n <p>All subsequent Ajax calls using any function will use the new settings, unless overridden by the individual calls, until the next invocation of <code>$.ajaxSetup()</code>.</p>\n <p><strong>Note:</strong> The settings specified here will affect <em>all</em> calls to <code>$.ajax</code> or Ajax-based derivatives such as <code>$.get()</code>. This can cause undesirable behavior since other callers (for example, plugins) may be expecting the normal default settings. For that reason we <em>strongly recommend against using this API</em>. Instead, set the options explicitly in the call or define a simple plugin to do so.</p>\n <p>For example, the following sets a default for the <code>url</code> parameter before pinging the server repeatedly:</p>\n <pre><code>\n$.ajaxSetup({\n url: \"ping.php\"\n});\n </code></pre>\n <p>Now each time an Ajax request is made, the \"ping.php\" URL will be used automatically:</p>\n <pre><code>\n$.ajax({\n // url not set here; uses ping.php\n data: { \"name\": \"Dan\" }\n});\n </code></pre>\n <div class=\"warning\">\n <p>Note: Global callback functions should be set with their respective global Ajax event handler methods&#x2014;<code><a href=\"/ajaxStart/\">.ajaxStart()</a></code>, <code><a href=\"/ajaxStop/\">.ajaxStop()</a></code>, <code><a href=\"/ajaxComplete/\">.ajaxComplete()</a></code>, <code><a href=\"/ajaxError/\">.ajaxError()</a></code>, <code><a href=\"/ajaxSuccess/\">.ajaxSuccess()</a></code>, <code><a href=\"/ajaxSend/\">.ajaxSend()</a></code>&#x2014;rather than within the <code>options</code> object for <code>$.ajaxSetup()</code>.</p>\n </div>\n "}]}