Created
June 3, 2013 11:07
-
-
Save magalhini/5697478 to your computer and use it in GitHub Desktop.
$promise for a piped POST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var asking = new $.Deferred(); | |
var feedback = asking.pipe(function (res) { | |
console.log('Sending:', res); | |
return $.post('/echo/json', res); | |
}); | |
// Simulate form submit... | |
asking.resolve('my details'); | |
asking.done(function () { | |
console.log('--- show loading...'); | |
}); | |
feedback.then(function () { | |
console.log('--- SUCCESS! Remove loading...'); | |
}, function () { | |
console.log('Error'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment