Created
October 29, 2019 13:53
-
-
Save macu/0ede8d2bb87c95a449712921c514bbf5 to your computer and use it in GitHub Desktop.
Detect AJAX response error codes using jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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