Skip to content

Instantly share code, notes, and snippets.

@Troland
Created June 25, 2018 16:00
Show Gist options
  • Save Troland/d4ad9790551af08a2899e5f84956f01a to your computer and use it in GitHub Desktop.
Save Troland/d4ad9790551af08a2899e5f84956f01a to your computer and use it in GitHub Desktop.
jquery ajax error
$.ajax({
type: 'GET',
url: {url},
success: function(data) {
alert('Success');
},
error: function(xhr, textStatus, errorThrown) {
if (xhr.readyState == 4) {
// HTTP error (can be checked by XMLHttpRequest.status and XMLHttpRequest.statusText)
} else if (xhr.readyState == 0) {
// Network error (i.e. connection refused, access denied due to CORS, etc.)
} else {
// something weird is happening
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment