I don't understand a thing about $.ajax, .done and .fail
I start my ajax call, assigning this to a variabile.
At next ajax call i test if variable is defined, and then i call abort.
I'm not able to undertsand if .abort() causes execution of .done or not.
If it causes .done, how to check status and detect aborted call ?
From http://api.jquery.com/jQuery.ajax/#jqXHR :
In particular, calling .abort() on the object will halt the request before it completes.
... so I understand that .done will not be fired after a .abort, right ?
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.
Just use ajax.abort(); } //then you make another ajax request $. ajax( //your code here );
Ajax requests do just that. With this, all codes following this one will execute immediately; you will not have to wait until the function returns. This way, your user would not have to wait for findItem() to return a result. Of course, because you still need an answer, you would have to include a callback.
abort() method aborts the request if it has already been sent. When a request is aborted, its readyState is changed to XMLHttpRequest.
The second argument to the fail
callback is textStatus
, for an aborted request that should be "abort"
. I wouldn't expect the done
callback to be fired.
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