Click here to show or hide the menubar.

Home >  Archive >  2010 >  December >  23

Previous / Next

A node.js module that does JSONP
By Dave Winer on Thursday, December 23, 2010 at 10:22 AM.

JSONP turns a bit of JSON into a bit of JavaScript.  permalink

BTW, when I was trying to figure out what JSONP was I kept encountering long-winded explanations that told me ad nauseum something that I already knew about cross-domain data access and the loophole that allows scripts to be run cross-domain. Basically this is a flaw in browser design that should probably be fixed instead of worked-around. But that's how it goes sometimes in software. permalink

In between all the history, the idea of JSONP usually never is actually explained. It's as if the writer used up all his or her energy explaining the crappy reason why we need JSONP in the first place. permalink

So I put all the crappy whining in this bit of sub-text and kept it simple "up there."  permalink

:-)"> ">permalink

I want a node.js module that does that. A web app that takes two params, the URL of a JSON file and the name of a callback. Example: permalink

http://hello.com/world?url=http://oy.org/random.json&callback=myLocalSubroutine permalink

What it would return is this: permalink

myLocalSubroutine (["Oregon", "Pizza", "Wheat"]) permalink

Assuming random.json contains a list: ["Oregon", "Pizza", "Wheat"]. permalink

Then Step 2 would simplify it to: permalink

http://oy.org/random.json?callback=myLocalSubroutine permalink

This, as I understand it, is what works best for JavaScript programmers working in the browser. permalink

I wanted to provide this functionality in Frontier, but my guys are polling this thing ever 5 seconds (which is BS, they shouldn't do that, but WTF) and that would cost me $90 per month and it wouldn't run very well as soon as their stuff got a few hundred users, which is what we hope happens. A lose-lose-lose. permalink

What we need is a bare-bones machine language thing that does this. Node.js would be ideal. permalink

Caveat: Of course, I'm sure something like this already exists! :-) permalink

RSS feed for Scripting News
This site contributes to the scripting.com community river.


© Copyright 1997-2012 Dave Winer. Last update: Thursday, December 23, 2010 at 10:33 AM Eastern. Last build: 8/26/2012; 6:04:17 PM. "It's even worse than it appears."

RSS feed for Scripting News

Previous / Next