Skip to content

Instantly share code, notes, and snippets.

@simensen
Created January 30, 2010 01:07
Show Gist options
  • Save simensen/290310 to your computer and use it in GitHub Desktop.
Save simensen/290310 to your computer and use it in GitHub Desktop.
jQuery('.emailLink').click(function(e) {
e.preventDefault();
var $link = jQuery(this);
var $sending = jQuery('<span>Sending...</span>');
$link.after($sending);
$link.hide();
var restoreCb = function() {
$link.show();
$sending.remove();
};
jQuery.ajax({
url: $link.attr('href'),
error: function(xhr, textStatus, errorThrown) {
// handle error
restoreCb();
},
success: function(data) {
// Do something with the data that is returned.
// Only success in as much as the HTTP request
// was a success!
restoreCb();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment