Smallest JSONp Implementation
Apr0611Apr 06, 11
Here's a tiny chunk of JavaScript I wrote while experimenting with writing an insanely small web chat client. I think this might be the worlds smallest JSONp implementation that doesn't suck.
/** Pico JSONp: */
function jsonp(u,cb){var a=jsonp._c=(jsonp._c||0)+1,b='picojsonp_'+a,c=document,d=c.body,s=c.createElement('script');window[b]=function()
{d.removeChild(s);cb.apply(cb,arguments);cb=c=d=s=null;};s.src=u.replace('{callback}',b);d.appendChild(s);}
/** Example usage: */
jsonp('http://example.com/timeline.json?callback={callback}', function(response) {
console.log(response);
});
Comments
tjKomal#
its cool bro...
Tgwizman#
mhm
Leave a Comment

