Skip to content

Instantly share code, notes, and snippets.

@Fractaliste
Created January 25, 2014 17:51
Show Gist options
  • Save Fractaliste/8620506 to your computer and use it in GitHub Desktop.
Save Fractaliste/8620506 to your computer and use it in GitHub Desktop.
Ajax inheritance
function customAjax(options) {
if (options.success) {
// I would like to save the callback
temporaryVariable = options.success;
}
// Then I want to add some actions before to execute the callback
options.success = function () {
// Some actions
console.log('Some actions');
// Then execute the previous callback
temporaryVariable();
};
return $.ajax(options);
}
customAjax({
url: "http://test.com",
success: function(event, data) {
console.log("Do something");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment