JSONP for cross-domain JavaScript access

I found a really cool site called PlainJS (http://plainjs.com), and within it a great trick for requesting data cross-domain called JSONP. I’d heard of this before, but never tried it out.

Here’s the code I used: JSONP and Mustache · GitHub

I made a simple Rails app to handle the JSON reply and to populate the database. Because I was running Rails locally, it was hosted at localhost:3000, and I hosted my test HTML page using Apache, so it was at al.local/api. Even though an Ajax request from al.local to localhost:3000 fails on two counts (host and port) to be from the Same Origin, this just works. I can add a new widget and see it reflected on the HTML page.

Walter


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

That’s very neat.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options