Return to Snippet

Revision: 35903
at November 15, 2010 05:05 by ebiansyah1402


Updated Code
<!DOCTYPE HTML>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Tumblr test</title>
</head>
<body>
	
	<div id="data">
		
	</div>
	
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
	
	<script type="text/javascript">
		var randomNum = Math.ceil(Math.random()*20); 

		$.getJSON('http://startupquote.com/api/read/json?filter=text&start='+randomNum+'&callback=?', 
		function(data) {		
			$.each(data.posts, function(i, posts){
				var photocaption = this["photo-caption"];

				$('<p>' + photocaption + '</p>').appendTo('#data');
				if ( i == 0 ) return false;
			});
		});
	</script>
	
</body>
</html>

Revision: 35902
at November 15, 2010 05:02 by ebiansyah1402


Updated Code
jQuery(document).ready(function($) {
	
	var randomNum = Math.ceil(Math.random()*20); 
	
	$.getJSON('http://startupquote.com/api/read/json?filter=text&start='+randomNum+'&callback=?', 
	function(data) {		
		$.each(data.posts, function(i, posts){
			var photocaption = this["photo-caption"];
			
			$('<p>' + photocaption + '</p>').appendTo('#random-quote');
			if ( i == 0 ) return false;
		});
	});
	
});

Revision: 35901
at November 15, 2010 05:00 by ebiansyah1402


Initial Code
jQuery(document).ready(function($) {
	
	var randomNum = Math.ceil(Math.random()*20); 
	
	$.getJSON('http://startupquote.com/api/read/json?filter=text&start='+randomNum+'&callback=?', 
	function(data) {		
		$.each(data.posts, function(i, posts){
			var photocaption = this["photo-caption"];
			
			$('<p>' + photocaption + '</p>').appendTo('#random-quote');
			if ( i == 0 ) return false;
		});
	});
	
});

Initial URL

                                

Initial Description
This example grab content from <a href="http://startupquote.com/">StartupQuote.com</a>. The ultra cool and super inspiring tumblr blog.

Initial Title
jq Grab random quote with jquery and Tumblr JSON

Initial Tags
jquery

Initial Language
JavaScript