Skip to content

Instantly share code, notes, and snippets.

@seanh
Created January 6, 2011 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save seanh/768283 to your computer and use it in GitHub Desktop.
Save seanh/768283 to your computer and use it in GitHub Desktop.
<!-- Import jQuery. -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
function fetchAndPrintPosts(id,num,tag)
{
// Read data from Tumblr, this creates the variable tumblr_api_read.
jQuery.ajax({
type: "GET",
url : "http://staff.tumblr.com/api/read/json?num=" + num + "&filter=text&tagged=" + tag,
dataType : "script",
success : function() { printPosts(id); }
});
}
function printPosts(id)
{
var element_to_append_to = document.getElementById(id);
var posts = tumblr_api_read["posts"];
...
}
fetchAndPrintPosts('latest_events',50,'events');
fetchAndPrintPosts('latest_press',50,'press');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment