« Pricing Changes for PublicDomainReprints.org Using XSLT for Very Large Files »
JSON Without Callbacks
Posted October 20, 2008 – 8:02 am by Yakov Shafranovich in ProgrammingDuring my investigations into Google Reader and iGoogle, I ran into an issue which has not been clearly addressed anywhere. The question is if a site provides a JSON feed without a callback function and you are using it on a different domain (meaning you cannot use XmlHttpRequest), can you still take advantage of it?
The short answer is no - JSON does not work in a pure client side environment without callbacks. This is due to the fact that JSON objects come back anonymous and when you include them in your page via SCRIPT tags, they do not initialize to anything. They must be passed to eval or to a function in order to become true Javascript objects. For example, this delicious feed is raw JSON. If you include it via a SCRIPT tag, it will not work.
An alternative is to use a callback, a proxy, something like Google’s Feeds API, XML HTTP Request if you are on the same domain or Flash if crossdomain.xml is defined properly.
Tags: javascript, json —
Permalink | Trackback URL | This post has










