Sunday, February 18, 2007

Firebug, Prototype, Blogger & Json

Alright, I've had enough. Dealing with javascript is now too easy. Look:



<script src="javascript/prototype.js"></script>
<script src="javascript/scriptaculous.js"></script>
<script>
function render_headlines(data) {
var entries = $A(data.feed.entry);
var ul = document.createElement('ul');

entries.each(function(entry) {
var li = document.createElement('li');
var a = document.createElement('a');
a.setAttribute('href', entry.link.$t);
a.appendChild(document.createTextNode(entry.title.$t));
li.appendChild(a);
ul.appendChild(li);
});

window.onload = function() {
$("headlines").appendChild(ul);
}
}
</script>
<script type="text/javascript" src="http://clockwerx.blogspot.com/feeds/posts/default?alt=json-in-script&callback=render_headlines"></script>

<div id="headlines" />



... which will get the ATOM feed of this blog as JSON, call render_headlines(); and append an ul to #headlines.
Post a Comment