Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What arguments are supplied to the function inside an ajax .done?

People also ask

How many arguments does our AJAX function call require?

The function accepts two arguments: The raw data returned from the server and the 'dataType' parameter.

What is AJAX done function?

With Ajax, web applications can send and retrieve data from a server, asynchronously, without interfering with the existing page's display and behavior. AJAX is not a programming language – it requires a built-in browser with the XMLHttpRequest object, and it uses JavaScript and HTML DOM to display the data.

What are the contents of AJAX?

AJAX stands for Asynchronous JavaScript And XML. In a nutshell, it is the use of the XMLHttpRequest object to communicate with servers. It can send and receive information in various formats, including JSON, XML, HTML, and text files.

What are required attributes for AJAX call?

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.


The arguments for .done() and .fail() are the same as the arguments for the corresponding success: and error: parameters for the $.ajax() function, namely:

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

and

.fail( function(jqXHR, textStatus, errorThrown) { ... } );

For the purposes of typescript, textStatus and errorThrown are strings, jqXHR is an Object, and data depends on what the remote server sends you.


The three parameters passed to the done handler are:

data, textStatus, jqXHR

You can read more here: http://api.jquery.com/jQuery.ajax/

  1. data is the response message
  2. textStatus will always be success in the done function
  3. jqXHR is the raw XMLHttpRequest

Check this out:

Methods (part of jqXHR and Deferred implementations, shown here for clarity only)

 .ajax().always(function(a, textStatus, b){});

Replaces method .complete() which was deprecated in jQuery 1.8. In response to successful transaction, arguments are same as .done() (ie. a = data, b = jqXHR) and for failed transactions the arguments are same as .fail() (ie. a = jqXHR, b = errorThrown). This is an alternative construct for the complete callback function above. Refer to deferred.always() for implementation details.

    .ajax().done(function(data, textStatus, jqXHR){});

Replaces method .success() which was deprecated in jQuery 1.8. This is an alternative construct for the success callback function above. Refer to deferred.done() for implementation details.

    .ajax().fail(function(jqXHR, textStatus, errorThrown){});

Replaces method .error() which was deprecated in jQuery 1.8. This is an alternative construct for the complete callback function above. Refer to deferred.fail() for implementation details.

    .ajax().then(function(data, textStatus, jqXHR){}, function(jqXHR, textStatus, errorThrown){});

Incorporates the functionality of .done() and .fail() methods. Refer to deferred.then() for implementation details.

    .ajax().pipe(function(data, textStatus, jqXHR){}, function(jqXHR, textStatus, errorThrown){});

Incorporates the functionality of .done() and .fail() methods, allowing the underlying Promise to be manipulated. Refer to deferred.pipe() for implementation details.