Skip to content

Instantly share code, notes, and snippets.

@chantastic
Last active August 6, 2019 13:04
Show Gist options
  • Save chantastic/5146764 to your computer and use it in GitHub Desktop.
Save chantastic/5146764 to your computer and use it in GitHub Desktop.
ajax boilerplate
var fetchingResource = null;
function AJAXBoilerplate () {
if(fetchingResource) {
fetchingResource.abort();
}
fetchingResource = $.ajax({
url: '/resource',
data: {},
cache: false,
timeout: 15000,
type: 'GET',
beforeSend: function () {},
complete: function () {
fetchingResource = null;
},
error: function () {
if (result.statusText != "abort");
},
success: function () {}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment