Skip to content

Instantly share code, notes, and snippets.

@jakl
Last active December 28, 2015 11:19
Show Gist options
  • Save jakl/7492088 to your computer and use it in GitHub Desktop.
Save jakl/7492088 to your computer and use it in GitHub Desktop.
Google doc jsonp test

Gdoc Jsonp

Google doc spreadsheets can be used as client-side-only data endpoints with the jsonp protocol

Here is a simple demo of my document that contains

name    	 age
--------------
mildred	   35
treebeard	 9,001
goku	     7

Demo

Blocks demo

Backend URL

My public google doc

Bibliography

Explanation article

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script src='index.js'></script>
<div class='data'></div>
$(function(){
entryTemplate = _.template("<div><span>Age is <%= age %></span> <span>while name is <%= name %>.</span></div>")
$.getJSON(
'https://spreadsheets.google.com/feeds/list/0AngeFDdGwfDydENTa3FWM05YYnlOMENCanpCZU4tZ0E/od6/public/values?alt=json-in-script&callback=?'
).done(function(data){
data.feed.entry.forEach(function(entry){
$('.data').append(entryTemplate({age: entry.gsx$age.$t, name: entry.gsx$name.$t}))
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment