JSFiddle - React, Tailwind, and code Playground
by Eric Hynds
JavaScript
// open your console!
function getData(){
return $.get('/echo/html/').success(function(){
console.log('Fires when the AJAX request succeeds');
});
}
function sweetAnimation(){
var dfd = $.Deferred();
dfd.done(function(){
console.log('Fires when the animation succeeds');
});
setTimeout(function(){
dfd.resolve( 'hi!' );
}, 1000);
return dfd.promise();
}
$.when( getData(), sweetAnimation() )
.then(function( ajaxResult, animationResult ){
console.log('Fires when BOTH sweetAnimation() AND the AJAX request succeed!');
});