In the documentation there is a list of possible values that textStatus might be if the error()
callback fires ("timeout", "error", "notmodified" and "parsererror") but nothing specified for the success()
event.
Are there any other values besides "success" that could be passed to the success()
callback? Is this documented anywhere?
You can check when exactly it returns "success" : // If successful, handle type chaining if ( status >= 200 && status < 300 || status === 304 ) { ... // If not modified if ( status === 304 ) { statusText = "notmodified"; ... // If we have data } else { try { ...
Yes, it is deprecated in jQuery 1.8 onwards. You should use . done() and use . fail() to catch the errors.
AJAX success is a global event. Global events are triggered on the document to call any handlers who may be listening. The ajaxSuccess event is only called if the request is successful. It is essentially a type function that's called when a request proceeds.
The ajaxStop() method specifies a function to run when ALL AJAX requests have completed. When an AJAX request completes, jQuery checks if there are any more AJAX requests. The function specified with the ajaxStop() method will run if no other requests are pending.
Success can only be called on success. So the easy answer is no.
Complete will always run, regardless of what how ajax did. So complete should be able to get and values textstatus can return.
On the forum I found textstatus can be any of these values
"timeout" "error" "notmodified" "success" "parsererror"
http://forum.jquery.com/topic/jquery-ajax-textstatus-documented
Success
and complete
are documented at here. You don't really need to worry about what textStatus is passed to the functions, it's all handled automatically. The success function is called when/if the call succeeds, and complete is called at the very end of everything else.
So, as an example from something I'm working on, I chained together three functions that are triggered when you click a section of the page: a div fades out, and when that's done it runs an ajax call. The success function updates the content of the div (while it's faded out), and then the complete function calls fadeIn on the div. So what it does is it fades out, updates, and fades back in with new content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With