$. Setting and significance of common Ajax () Parameters

Source: Internet
Author: User

Which of the following is more common?

<HTML>
<Head>
<SCRIPT type = "text/JavaScript">
Function ABC (){
$. Ajax ({
Async: True,

/* Whether the request is asynchronous. The object is used for asynchronous requests. Therefore, the value is generally the same, and the value is always true */
Cache: false,/* Indicates whether to use cache */
Global: True,/* Whether to trigger a set global event, such as $ ("# ID"). ajaxstart () or

$ ("# ID"). ajaxsend (), and other events */
Timeout: 3000,/* defines the request timeout time. This setting overwrites the global value, in milliseconds */
Username: "",/* defines the Server HTTP request username, which is related to server settings */
Password: "",/* defines the HTTP request password of the server, which is related to the server settings */
Type: "Post",/* define the data sending Method */
URL: "jx. asp",/* define the request URL */
Data: {AA: "BB"},/* data value pair to be sent to the server */
Context: $ (". m"),/* specifies the object in the callback function. If the value is written

Document. Body is valid for the entire window document. Here, it is a div selected with class, which will be viewed after execution.

The selected div is referred to by this in the callback function, thus changing the color.

Copy all the code, and then import the corresponding jquery file to execute */
Beforesend: function () {alert ("before request") ;},/* function to be executed before request sending */
Datatype: "text",/* define the returned data type */
Success: function(aa00000000alert(aa0000000000000000(this0000.css ("background-color", "#666666") ;},/* request successful

The function to be executed. Pay attention to a parameter of the function and capture the returned data */
Complete: function (xhr, TS) {alert (TS) ;},/* The function executed when the request is completed (whether or not it is successful,

Pay attention to the use of the two parameters of the function. The latter parameter is the Request status value, which is displayed by alert ().

The code in this article is success, indicating that the request is successful */
Error: function () {alert ("an error occurred");}/* function executed when a request error occurs */
});
}
</SCRIPT>
</Head>
<Body>
<Div id = "D" name = "ID" style = "width: 200px; Height: 100px;"> BBB </div>
<Div class = "M" name = "M" style = "width: 200px; Height: 100px;"> BBB </div>
<Button id = "II" onclick = "ABC ()"> load </button>
</Body>
</Html>
The preceding parameters are not all of them, and some of them are not commonly used and are not written in.

Related Article

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.