Render "cross-domain" content on the client-side with JSONP feeds & jQuery
Blog :Tech Tips, Tricks & Trivia
Date: 5/27/2012 5:48:00 PM
When websites provide Feeds of their content, they not only allow that content to be read through Feed readers like Google Reader but also let other sites consume that content programmatically. These feeds can be in various formats like RSS, Atom, JSON, JSONP.
Instead of scraping content from sites they don't own, developers can use RSS, Atom & JSON feeds with server-side programming languages to display that content on their own sites.
The P in JSONP stands for "padding". A JSONP feed is same as a JSON feed except that the feed provider pads the results with a bit more information. JSONP wraps the JSON-formatted response in a function call named by the developer. It allows "cross-domain" feed content to be used via a callback function.
A JSONP feed can be consumed easily using the jQuery ajax() & getJSON() methods.
According to the ProgrammableWeb website, which has been doing a great job of cataloging web-based APIs, there are currently 360 services that offer JSONP feeds. This is good news for jQuery developers.