views:

232

answers:

2

Hi all, I'm starting a project where I need to display my wife's picture books on her blog. I've got the books' data on a database - couchdb - and I want to write a player she can easily embed in her blog. I've got most of the player written in Html, JavaScript & jQuery.

Next, I need to write the html and javascript code to encapsulated my player so it can be easily and safely embedded in any html doc. Of course, it's the first time I do this.

Any tips?

+1  A: 

Are you making any http requests from your javascript to another domain? If so you'll need to use an IFrame because you can't make cross domain requests with javascript.

Nick
thanks, I do and your tip is very helpful.
daonb
you can't make cross-domain ajax calls with javascript. You can however host javascript on a different server.You could do this by hosting the javascript that does what you need and supplies the data needed to do it, that you can then load in a script tag. This is how most javascript widgets on pages like iGoogle work and sounds like exactly what you are describing.
Jeremy Wall
+1  A: 

If it's cross domain then what you need is an embeddable script tag(s) that does the work.

See JSONP for an example of one way you could get the data across the domain boundary.

http://remysharp.com/2007/10/08/what-is-jsonp/ http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/

iGoogle widgets and such use this sort of approach with success.

Jeremy Wall
Agreed. I'll take JSONP over IFrames anytime and day
Pablo Fernandez