Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the parameters sent to .always in jQuery?

I can't find the documentation on what are the parameters for the always() method.

Right now, I'm just using:

$.post("foo.do", {
    ...
}, function(data) {
    ...
}).fail(function(jqXHR, textStatus, errorThrown) {
    ...
}).always(function() {
    ...
});
like image 239
Paul Vargas Avatar asked Oct 11 '14 18:10

Paul Vargas


People also ask

Which parameters are being used for the jQuery AJAX method?

Parameters: The list of possible values are given below: type: It is used to specify the type of request. url: It is used to specify the URL to send the request to. username: It is used to specify a username to be used in an HTTP access authentication request.

Can you send data in a GET request?

GET is an HTTP method for requesting data from the server. Requests using the HTTP GET method should only fetch data, cannot enclose data in the body of a GET message, and should not have any other effect on data on the server.


1 Answers

The documentation is in jqXHR section of the $.ajax entry. 1

The parameters are as follows:

jqXHR.always(function( data|jqXHR, textStatus, jqXHR|errorThrown ) { });

  • If an error occurred:

    jqXHR.always(function( jqXHR, textStatus, errorThrown ) { });
    
  • And otherwise:

    jqXHR.always(function( data, textStatus, jqXHR ) { });
    

Notes

  1. Thanks to Mike's comment.
like image 66
Paul Vargas Avatar answered Sep 30 '22 12:09

Paul Vargas