Can you defer statusCode in jquery 1.5?

I see that they have added a function for status codes

statusCode (added 1.5) Card Default: {} A card of numeric HTTP codes and functions called when the response has the corresponding code. For example, the following warning when the response status is 404:

$.ajax({   statusCode: {404: function() {
    alert('page not found');   } }); 

If the request is successful, the code status functions take the same parameters as a success callback; if this leads to an error, they accept the same parameters as the error

I am wondering if you can do something like $.ajax({...}).statusCode(function(){...});

Simliar how can you do

var jqxhr = $.ajax({ url: "example.php" })
    .success(function() { alert("success"); })
    .error(function() { alert("error"); })
    .complete(function() { alert("complete"); })
+3
source share
1 answer

, . , , , , , , , - , HTTP, . . .

$.ajax({ url: "example.php" })
    .statusCode({
        200: function(){
            alert('success');
        },
        404: function(){
            alert('not found');
        }
    });
+4

Source: https://habr.com/ru/post/1795802/


All Articles