mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add specs for jqXHR object returned by $.ajax
The tests are corresponding to the syntax listed in its website: http://api.jquery.com/jQuery.ajax/#jqXHR
This commit is contained in:
+32
-1
@@ -151,7 +151,38 @@ function test_ajax() {
|
||||
dataType: "script"
|
||||
});
|
||||
|
||||
// treat $.ajax() as a promise (as of 1.8)
|
||||
// Test the jqXHR object returned by $.ajax() as of 1.5
|
||||
// More details: http://api.jquery.com/jQuery.ajax/#jqXHR
|
||||
|
||||
// done method
|
||||
$.ajax({
|
||||
url: "test.js"
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
console.log(data, textStatus, jqXHR);
|
||||
});
|
||||
|
||||
// fail method
|
||||
$.ajax({
|
||||
url: "test.js"
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
console.log(jqXHR, textStatus, errorThrown);
|
||||
});
|
||||
|
||||
// always method with successful request
|
||||
$.ajax({
|
||||
url: "test.js"
|
||||
}).always((data, textStatus, jqXHR) => {
|
||||
console.log(data, textStatus, jqXHR);
|
||||
});
|
||||
|
||||
// always method with failed request
|
||||
$.ajax({
|
||||
url: "test.js"
|
||||
}).always((jqXHR, textStatus, errorThrown) => {
|
||||
console.log(jqXHR, textStatus, errorThrown);
|
||||
});
|
||||
|
||||
// then method (as of 1.8)
|
||||
$.ajax({
|
||||
url: "test.js"
|
||||
}).then((data, textStatus, jqXHR) => {
|
||||
|
||||
Reference in New Issue
Block a user