Ajax Methods
The methods listed in the following table are common jQuery Ajax methods that require much less code than standard Ajax.
HTML Example
We will use the following HTML for the examples listed below.
ajaxStart() Method
The ajaxStart() method specifies a function to be run when an Ajax request starts. A function specified with the ajaxStart() method will run when the request is started.
Syntax
ajaxComplete() Method
The ajaxComplete() method specifies a function to be run when an Ajax request completes. A function specified with the ajaxComplete() method will run when the request is completed, even if the function was not successful.
Syntax
ajaxStop() Method
The ajaxStop() method specifies a function to run when all of the Ajax requests have completed their execution. When an Ajax request completes, jQuery will check to see if there are any other Ajax requests to execute. The function defined with the ajaxStop() method will execute if no other requests are pending.
Syntax
ajaxSucess() Method
The ajaxSuccess() method specifies a function to be run when an Ajax request is successfully completed.
Syntax
ajaxSend() Method
The ajaxSend() method specifies a function to execute prior to an Ajax requests being sent to the server.
Syntax
ajaxError() Method
The ajaxError() method specifies a function to be executed when an Ajax request fails. In the example below, you can change the source location of the file defined in the load() method to trigger this method.