Last active
August 29, 2015 13:57
-
-
Save kylerush/9361437 to your computer and use it in GitHub Desktop.
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
| jQuery.get('/account/info').always(function(data, textStatus, jqXHR){ | |
| if(jqXHR.status === 200){ | |
| try{ | |
| if(typeof data.userName === 'string'){ | |
| if(data.userName !== ''){ | |
| jQuery('#user-name').text(data.userName); | |
| } else { | |
| //handle the error, update the DOM to inform user what happened | |
| } | |
| } | |
| } catch(error){ | |
| //handle the error, update the DOM to inform user the api is down | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment