Is there any function equivalent to always (jQquery)?
See original GitHub issueI often make an ajax calls with some callbacks with error or not (jQuery ajax always() callback), specially if it’s some recursive functionality, ex:
$.ajax({
url: "example.php",
type: 'get',
})
.done(function(resp) {
alert( "success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "complete" ); // <-- always happens
});
I was woundering if there is any axios equivalent? Instead of doing this mess:
axios.get( "example.php").then(response => {
alert('success');
alert('complete'); // <--- same thing here
}).catch(function (error) {
alert(error);
alert('complete'); // <-- and here
});
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
Is there an equivalent to Python's all function in JavaScript or ...
Apparently, it does exist: Array.prototype.every . Example from mdn: function isBigEnough(element, index, array) { return (element >= 10); ...
Read more >jQuery.get( url [, data ] [, success ] [, dataType ] )Returns: jqXHR
A callback function that is executed if the request succeeds. Required if dataType is provided, but you can use null or jQuery.noop as...
Read more >5 jQuery.each() Function Examples - SitePoint
jQuery's each() function is used to loop through each element of the target jQuery object — an object that contains one or more...
Read more >Remove jQuery dependency from the once feature | Drupal.org
once.find (new function not previously possible with the jQuery implementation). Backwards compatibility. If code is relying on an existing once ...
Read more >You Might Not Need jQuery
jQuery and its cousins are great, and by all means use them if it makes it easier to develop your application. If you're...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Try the following (note the second
then
):I’d like to point out a couple things:
.then()
won’t fire if the.catch()
is not specified..always()
would be a better solution, for syntactic sugar reasons.