views:

143

answers:

2

I want to create a simple online poll application. I have created a backend in python that handles vote tracking, poll display, results display and admin setup. However, if I wanted a third party to be able to embed the poll in their website, what would be the recommended way of doing so? I would love to be able to provide a little javascript to drop into the third parties web page, but I can't use javascript because it would require a cross-domain access. What approach would provide an easy general solution for third parties?

+1  A: 

Make your app into a Google Gadget, Open Social gadget, or other kind of gadgets -- these are all designed to be embeddable into third-party pages with as little fuss as possible.

Alex Martelli
Thanks for the idea! I'm actually more interested in figuring out a good approach to the problem rather than deferring it (i.e. I'd like to know how Google does it :) )
Daniel
+1  A: 

IFrame is the easiest no muss no fuss solution if you want to allow postbacks.

Or, this is a bit left field and oldschool, but could you use a 1x1 transparent gif as your vote submission? They click the link (radio/span/whatever), you set the src of an image to something that lives on your server. Something like

document.getElementById('voteImage').src='http://your.server/vote.html?pollidentifier=123&vote=4'

where vote.html is your server side code for processing a vote, poll identifier is the way of telling what poll it is, and vote is the vote they've chosen. All vote.html has to do is return something that smells like an image and the browser will be happy. Obviously you'll need to put stuff in place to stop people faking up votes, but an image + cookies is what the old timers used to use before that new fandangled xhr came along.

Dan F