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:
Junle Li
2014-06-11 01:13:40 +08:00
parent fc628f15ad
commit 52678f3b87
+32 -1
View File
@@ -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) => {