Skip to content

Instantly share code, notes, and snippets.

View kylerush's full-sized avatar

Kyle Rush kylerush

  • New York, NY
View GitHub Profile
@kylerush
kylerush / default.js
Created March 5, 2014 03:44
Code example for a blog post "Tips for consuming JSON APIs in JavaScript."
jQuery.get('/account/info', function(data){
jQuery('#user-name').text(data.userName);
});
jQuery.get('/account/info', function(data){
jQuery('#user-name').text(data.userName);
});
jQuery.get('/account/info').always(function(data, textStatus, jqXHR){
if(jqXHR.status === 200){
jQuery('#user-name').text(data.userName);
}
});
jQuery.get('/account/info').always(function(data, textStatus, jqXHR){
if(jqXHR.status === 200){
try{
jQuery('#user-name').text(data.userName);
} catch(error){
jQuery.get('/account/info').always(function(data, textStatus, jqXHR){
if(jqXHR.status === 200){
try{
if(typeof data.userName === 'string'){
if(data.userName !== ''){
jQuery.get('/account/info').always(function(data, textStatus, jqXHR){
if(jqXHR.status === 200){
try{
if(typeof data.userName === 'string'){
if(data.userName !== ''){
dist/
blog/
post1.html
post2.html
post3.html
index.html
src/
content/
blog/
post1.hbs
assemble: {
options: {
layoutdir: '<%= config.src %>/templates/layouts',
},
posts: {
options: {
flatten: true,
layout: 'entry.hbs',
ext: '.html'
},
<div class="clear code-block">
<pre class="brush: xml">
<div id="container">
<h1><a>DEMO: Use the Flickr API, JavaScript (jQuery), AJAX and JSON to Build a Photo Wall <span>by Kyle Rush</span></a></h1>
<a id="a-link" href="http://www.flickr.com/photos/kylerush/">Click Here to See My Flickr Photos</a>
<div id="tut-info" class="clearfix">
<a>View Tutorial &gt;&gt;</a>
<a>How to Use the Flickr API &gt;&gt;</a>
<a href="http://www.kylerush.net">kylerush.net &gt;&gt;</a>
<div class="clear code-block">
<pre class="brush: css">
body, html {background: #000; font-size: 12px;}
#container {width: 810px; margin: 0 auto 0 auto;}
#notice {color: #fff; font-weight: bold; font-size: 15px; font-style: italic;}
h1 {font-size: 38px; line-height: 45px;}
h1 span {font-size: 16px; color: #ff0084;}
h1 a:hover span {color: #fff;}
#tut-info {width: 810px; margin: 0 0 20px 0;}
#tut-info a {float: left; display: block; background: #fff; font-size: 20px; padding: 20px 20px; font-weight: bold; margin: 0 15px 0 0;}