Skip to content

Instantly share code, notes, and snippets.

@verticalgrain
Created December 22, 2016 23:19
Show Gist options
  • Select an option

  • Save verticalgrain/36800080bd15fbaa4d851fde6f37f2be to your computer and use it in GitHub Desktop.

Select an option

Save verticalgrain/36800080bd15fbaa4d851fde6f37f2be to your computer and use it in GitHub Desktop.
jqXHR success and error logging example for $.get
var request = $.get('http://wp-recipes/wp-json/wp/v2/posts', {}, function(data, textStatus, jqXHR){
// Do some stuff
}, 'json');
request.success(function(result) {
console.log('success:');
console.log(result);
});
request.error(function(jqXHR, textStatus, errorThrown) {
if (textStatus == 'timeout')
console.log('Timeout');
if (textStatus == 'error')
console.log('error:');
console.log(errorThrown);
console.log(jqXHR);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment