Singpolyma

Archive of "JSONP"

Archive for the "JSONP" Category

JSONP in IE

Posted on

Another post based on a previous tweet. This took me at least an hour to debug, so I thought it might be worthwhile sharing.

IE, apparently, gets unhappy when you append nodes to the end of a node it hasn’t finished rendering yet. In practice, this means it blows up when you say document.body.appendChild before the page has loaded. The easy solution? Append to a node that has already loaded! What node is almost guaranteed to be there when the body is rendering? The head node of course! Here is code:

document.getElementsByTagName('head')[0].appendChild(script);

JSON from Google

Posted on

JSON (and particularly JSONP) is one of the most useful data formats for hackers. For quite some time we have had to do all sorts of hackish things to transform the data available from Google services to JSON(P). No longer.

Blogger, Google Calendar, and Google Base now all support JSONP. This was announced on Blogger Buzz and is perhaps one of the greatest advances in hackability in (at least recent) Google history.

On top of this, SearchMash (a Google susiduary) now offers JSON feeds of Google’s Web, Images, Blog, and Video searches. For JSONP a proxy service is required, but this still allows for getting Google’s data out where we can hack with it.

One thing that this will mean very soon is an upgrade to peek-a-boo for BETA that makes use of this and will definately be faster.

Del.icio.us JSONP is Native!

Posted on

For quite awhile now, del.icio.us has offered JSON support, but not a proper JSONP implementation. I even wrote my own proxying script to fix this oversight. It seems that that will no longer be necessary. If you pass callback=CALLBACK to a del.icio.us JSON feed it will now output proper JSONP that does not set the Delicious.posts variable (easy to fix in your callback function) but calls CALLBACK with the JSON object as a parameter. Compare these:
http://del.icio.us/feeds/json/singpolyma.techblog/
http://del.icio.us/feeds/json/singpolyma.techblog/?callback=CALLBACK
There has, as yet, been no official announcement on the del.icio.us blog, so this feature may yet be pulled like some others have, but I hope they will not. Hopefully I will soon be modifying my version of FreshTags to make good use of this native JSONP support.