$.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