You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Code to run if the request fails; the raw request and
42
-
// status codes are passed to the function
43
-
error: function( xhr, status, errorThrown ) {
44
-
alert( "Sorry, there was a problem!" );
45
-
console.log( "Error: " + errorThrown );
46
-
console.log( "Status: " + status );
47
-
console.dir( xhr );
48
-
},
49
-
50
-
// Code to run regardless of success or failure
51
-
complete: function( xhr, status ) {
52
-
alert( "The request is complete!" );
53
-
}
54
-
});
55
53
```
56
54
57
55
**Note:** Regarding the `dataType` setting, if the server sends back data that is in a different format than you specify, your code may fail, and the reason will not always be clear, because the HTTP response code will not show an error. When working with Ajax requests, make sure your server is sending back the data type you're asking for, and verify that the `Content-type` header is accurate for the data type. For example, for JSON data, the `Content-type` header should be `application/json`.
@@ -68,7 +66,15 @@ Set to `false` if the request should be sent synchronously. Defaults to `true`.
68
66
69
67
Whether to use a cached response if available. Defaults to `true` for all `dataType`s except "script" and "jsonp". When set to `false`, the URL will simply have a cachebusting parameter appended to it.
70
68
71
-
#### complete
69
+
#### done
70
+
71
+
A callback function to run if the request succeeds. The function receives the response data (converted to a JavaScript object if the `dataType` was JSON), as well as the text status of the request and the raw request object.
72
+
73
+
#### fail
74
+
75
+
A callback function to run if the request results in an error. The function receives the raw request object and the text status of the request.
76
+
77
+
#### always
72
78
73
79
A callback function to run when the request is complete, regardless of success or failure. The function receives the raw request object and the text status of the request.
74
80
@@ -84,17 +90,10 @@ The data to be sent to the server. This can either be an object or a query strin
84
90
85
91
The type of data you expect back from the server. By default, jQuery will look at the MIME type of the response if no `dataType` is specified.
86
92
87
-
#### error
88
-
89
-
A callback function to run if the request results in an error. The function receives the raw request object and the text status of the request.
90
-
91
93
#### jsonp
92
94
93
95
The callback name to send in a query string when making a JSONP request. Defaults to "callback".
94
96
95
-
#### success
96
-
97
-
A callback function to run if the request succeeds. The function receives the response data (converted to a JavaScript object if the `dataType` was JSON), as well as the text status of the request and the raw request object.
0 commit comments