Skip to content

Instantly share code, notes, and snippets.

@AndrewGaspar
Last active December 24, 2015 15:49
Show Gist options
  • Save AndrewGaspar/6823725 to your computer and use it in GitHub Desktop.
Save AndrewGaspar/6823725 to your computer and use it in GitHub Desktop.
Some typical asynchronous behavior
function handleFoobar(error, foobar) {
if(error) output(error);
var bar = deFoo(foobar);
// Matrix multiplication or something
output(bar);
}
fooButton.on("click", function (evt) {
$.get("/foobar/1", handleFoobar);
$.get("/foobar/2", handleFoobar);
});
kittyButton.on("click", function(evt){
$.ajax({
type: "PUT",
url: "/kitty/1337",
data: { kitty: "Mustachio", what: "Got totes clicked." }
}).then(function(updatedKitty) {
writeLocal(updatedKitty);
}, function (error) {
output(error);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment