Created
December 22, 2016 23:19
-
-
Save verticalgrain/36800080bd15fbaa4d851fde6f37f2be to your computer and use it in GitHub Desktop.
jqXHR success and error logging example for $.get
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
| 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