Saturday, January 16, 2010

OpenBD gets native JSONP support


However, what if you wish your services to be consumed by a Javascript function outside of your own domain? Cross-domain scripting will prevent this. So how do the likes of delicious.com offer such Javascript integrations for their services?



You achieve this by using JSONP (JSON with Padding) and this lets you achieve cross-domain data fetching.



JSONP requires a little assistance from both the server and the client inorder for it to work. JSONP works by wrapping the returning JSON packet in () and prepending a name to make it into a Javascript document.



The majority of Javascript libraries support JSON from their native core. JQuery supports it using $.getJSON method, which simply asks that you append the URI parameter "callback=?" to the end of the remote URL and it will do all the marshalling of data for you.




Another extremely slick addition to OpenBD! It's available in the nightly build. Read more at the full blog post (link above).

No comments: