There are various reasons why you may encounter different examples:
- Some arguments can be optional or of mixed type.
- The naming of arguments in callback functions is at the discretion of the author.
- The usage of callbacks and their arguments can vary based on the version of jQuery being used by the author.
It is advisable to always refer to the documentation for the specific version of .ajax that you are working with. If you seek a standard approach to using .ajax in your application, following the syntax provided in the documentation is your safest bet:
http://api.jquery.com/jquery.ajax/
The documentation elaborates on the changes introduced in each version of jQuery, allowing you to avoid potential issues in your application by staying informed.
As stated in the jQuery documentation:
complete
Type: Function( jqXHR jqXHR, String textStatus )
A function executed upon completion of the request, after both success and error callbacks are triggered. It receives two arguments: the jqXHR object (XMLHTTPRequest in jQuery 1.4.x) and a string indicating the request status ("success", "notmodified", "nocontent", "error", "timeout", "abort", or "parsererror"). Beginning from jQuery 1.5, the complete setting can accommodate an array of functions, all of which will be called sequentially. This constitutes an Ajax Event.
success
Type: Function( Anything data, String textStatus, jqXHR jqXHR )
A function to handle successful requests. It takes three parameters: the server's response data formatted based on the dataType parameter or dataFilter callback function if specified, a status description, and the jqXHR object. Starting from jQuery 1.5, the success setting permits an array of functions to be defined, each of which will be invoked in order. This also serves as an Ajax Event.
error
Type: Function( jqXHR jqXHR, String textStatus, String errorThrown )
An error-handling function utilized when a request fails. It receives three arguments: the jqXHR object (XMLHttpRequest in jQuery 1.4.x), an error description, and optionally an exception object if present. The second argument can include values like "timeout," "error," "abort," and "parsererror" apart from null. When encountering an HTTP error, errorThrown captures the textual representation of the HTTP status, such as "Not Found" or "Internal Server Error." From jQuery 1.5 onwards, the error setting supports an array of functions, running one after the other. Note: this handler does not apply to cross-domain script or cross-domain JSONP requests. This also qualifies as an Ajax Event.