Is it that
success()
returns earlier thancomplete()
?
Yes; the AJAX success()
method runs before the complete()
method.
Below is a diagram illustrating the process flow:
It is important to note that
-
The
success()
(Local Event) is only called if the request was successful (no errors from the server, no errors with the data). -
On the other hand, the
complete()
(Local Event) is called regardless of if the request was successful, or not. You will always receive a complete callback, even for synchronous requests.
… more details on AJAX Events here.