Skip to content

Instantly share code, notes, and snippets.

@macu
Created October 29, 2019 13:53
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 macu/0ede8d2bb87c95a449712921c514bbf5 to your computer and use it in GitHub Desktop.
Save macu/0ede8d2bb87c95a449712921c514bbf5 to your computer and use it in GitHub Desktop.
Detect AJAX response error codes using jQuery
$.post('/ajax/test', {
field,
}).then(response => {
// Success
}).fail((jqXHR) => {
if (jqXHR.status === 409) {
alert('Conflict');
} else {
alert('Error code: ' + jqXHR.status);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment