Skip to content

Instantly share code, notes, and snippets.

@terrymun
Last active August 29, 2015 14:11
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 terrymun/58cb5008c4bea03e6004 to your computer and use it in GitHub Desktop.
Save terrymun/58cb5008c4bea03e6004 to your computer and use it in GitHub Desktop.
Better $.ajax() requests — using new jqXHR promises and deferred objects
$.ajax({
data: someData,
dataType: 'json',
url: '/path/to/script'
}).done(function(data) {
// If successful
console.log(data);
}).fail(function(jqXHR, textStatus, errorThrown) {
// If fail
console.log(textStatus + ': ' + errorThrown);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment