Remote JSON made easy with jQuery
There are times when people resort to server side code instead of keeping code on client side to skip through voluminous JavaScript code and the additional technical logic that needs to be maintained.
One such scenario is when the JSON data for certain UI-related logic has to come from a different site. Due to http://en.wikipedia.org/wiki/Same_origin_policy restriction, this might not be possible with straight JavaScript. Here, the most favorite workaround is either to set up a proxy on the server side which calls the cross domain data and then use it on the client side, or move the handling of the logic complete to the server side. This is fine for certain not-so-popular sites with limited APIs. But not for Web 2.0-aware sites, especially for almost all of the social networking sites.
Why so? This is because, most of these sites offer a callback functionality whenever a URL is invoked requesting the data. While this would not make any difference for a browser to bypass the Same Origin Policy restriction, this could be utilized to a developer’s advantage. The callback-enabled URLs wraps the JSON data with a function. For example, consider this JSON data:
[
{
name:"Krupa",
age:20,
department:"IT"
}
]

