Skip to content

Instantly share code, notes, and snippets.

@alissonbrunosa
Last active June 26, 2016 03:36
Show Gist options
  • Select an option

  • Save alissonbrunosa/4484b7ac2ade9c81efe0bbeb60daf35b to your computer and use it in GitHub Desktop.

Select an option

Save alissonbrunosa/4484b7ac2ade9c81efe0bbeb60daf35b to your computer and use it in GitHub Desktop.
$.ajax({
url: 'url-chamada',
success: function(a,b,c) {
// Do something if sucess
},
statusCode: {
401: function() {
//Do something if status code is 401.
}
}
});
// Caso tenha mais chamadas ajax e queria fazer um comportamento global.
$( document ).ajaxComplete(function( event, xhr, settings ) {
if(xhr.status === 401) {
// Do something if status == 401
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment