$.ajax () method

Source: Internet
Author: User

$.ajax () The setting of common parameters and its significance

The more common ones are the following.

<script type= "Text/javascript" >
Function abc () {
$.ajax ({
Async:true,

/* Whether the request is asynchronous, the purpose of this object is to asynchronous request, so this value is generally unchanged, constant is true*/
Cache:false,/* Whether to use cache */
Global:true,/* Whether to trigger a global event that has been set, such as $ ("#id"). Ajaxstart () or

$ ("#id"). Ajaxsend (), etc. */
timeout:3000,/* Define request Timeout, this setting overrides global, number of milliseconds */
Username: "",/* Define the server HTTP request username, which is related to server settings */
Password: "",/* Define the server HTTP request password, related to the server's settings */
Type: "POST",/* defines how data is sent */
URL: "Jx.asp",/* Define the requested url*/
DATA:{AA: "BB"},/* Data value pair to be sent to the server */
Context:$ (". M"),/* Specifies which object in the callback function this refers to, and if the value is written

Document.body is valid for the entire window document, here is a div selected with class, which is executed to see

, the selected Div is referred to in the callback function with this, thus changing the color, the chapter

Copy all the code, and then draw the corresponding jquery file can be executed */
Beforesend:function () {alert (before request);},/* function to execute before sending request */
DataType: "Text",/* defines the type of data returned */
Success:function (AA) {alert (AA); $ (this). CSS ("Background-color", "#666666");},/* Request succeeded

The function to be executed, note one of the parameters of the function, and to catch the return data */
Complete:function (xhr,ts) {alert (TS);},/* The function executed when the request completes (whether or not successful).

Notice the use of the two parameters of the function, and the latter parameter is the requested status value, which pops up with alert ().

, the code of this article is executed after the display is success, indicating that the request was successful */
Error:function () {alert ("error occurred");} /* function to execute when request error */
});
}
</script>
<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>

$.ajax () method

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.