Skip to content

Instantly share code, notes, and snippets.

@magalhini
Created June 3, 2013 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magalhini/5697478 to your computer and use it in GitHub Desktop.
Save magalhini/5697478 to your computer and use it in GitHub Desktop.
$promise for a piped POST
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