JQuery Ajaxsetup () method

Source: Internet
Author: User
Tags character set

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.