Skip to content

Instantly share code, notes, and snippets.

View jlengstorf's full-sized avatar
💭
partyin

Jason Lengstorf jlengstorf

💭
partyin
View GitHub Profile
@jlengstorf
jlengstorf / gist:2760212
Created May 21, 2012 01:28
Code example from "JSON: What It Is, How It Works, & How to Use It"
function loadFlickr(flickrid)
{
$('#feed').html('<span><img src="/blog/images/lightbox-ico-loading.gif" alt=""></span>');
$.ajax({
type:'GET',
url:"http://api.flickr.com/services/feeds/photos_public.gne",
data:"id="+flickrid+"&lang=en-us&format=json&jsoncallback=?",
success:function(feed) {
// Do something with the response
},
<?php $href = is_front_page() ? 'class="scrolly" href="' : 'href="/'; ?>
               <ul>
                   <li><a <?php echo $href; ?>#about">   about copter </a></li>
                   <li><a <?php echo $href; ?>#process"> our process  </a></li>
                   <li><a <?php echo $href; ?>#work">    our work     </a></li>
                   <li><a <?php echo $href; ?>#start">   get started  </a></li>
               </ul>
@jlengstorf
jlengstorf / gist:2760279
Created May 21, 2012 02:09
#1 Code example from "JSON: What It Is, How It Works, & How to Use It"
var jason = {
"age" : "24",
"hometown" : "Missoula, MT",
"gender" : "male"
};
@jlengstorf
jlengstorf / gist:2760312
Created May 21, 2012 02:31
#2 Code example from "JSON: What It Is, How It Works, & How to Use It"
document.write('Jason is ' jason.age); // Output: Jason is 24
document.write('Jason is a ' jason.gender); // Output: Jason is a male
@jlengstorf
jlengstorf / gist:2760314
Created May 21, 2012 02:32
#3 Code example from "JSON: What It Is, How It Works, & How to Use It"
var family = [{
"name" : "Jason",
"age" : "24",
"gender" : "male"
},
{
"name" : "Kyle",
"age" : "21",
"gender" : "male"
}];
@jlengstorf
jlengstorf / gist:2760322
Created May 21, 2012 02:33
#4 Code example from "JSON: What It Is, How It Works, & How to Use It"
document.write(family[1].name); // Output: Kyle
document.write(family[0].age); // Output: 24
@jlengstorf
jlengstorf / gist:2760326
Created May 21, 2012 02:35
#5 Code example from "JSON: What It Is, How It Works, & How to Use It"
var family = {
"jason" : {
"name" : "Jason Lengstorf",
"age" : "24",
"gender" : "male"
},
"kyle" : {
"name" : "Kyle Lengstorf",
"age" : "21",
"gender" : "male"
@jlengstorf
jlengstorf / gist:2760328
Created May 21, 2012 02:36
#6 Code example from "JSON: What It Is, How It Works, & How to Use It"
document.write(family.jason.name); // Output: Jason Lengstorf
document.write(family.kyle.age); // Output: 21
document.write(family.jason.gender); // Output: male
@jlengstorf
jlengstorf / gist:2760335
Created May 21, 2012 02:38
#7 Code example from "JSON: What It Is, How It Works, & How to Use It"
[Exception... "Access to restricted URI denied" code: "1012"
nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)"
location: "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js Line: 19"]
@jlengstorf
jlengstorf / gist:2760340
Created May 21, 2012 02:39
#8 Code example from "JSON: What It Is, How It Works, & How to Use It"
$.ajax(
type:'GET',
url:"http://example.com/users/feeds/",
data:"format=json&id=123",
success:function(feed) {
document.write(feed);
},
dataType:'jsonp'
);