javascriptdojojsonpcorsgoogle-cdn

Cross-origin requests on Google CDN


I am trying to load a file with a .json extension from the Google CDN:

//ajax.googleapis.com/ajax/libs/dojo/1.8/dojox/geo/charting/resources/data/USStates.json

Standard xhr requests fail because of the cross-origin policy. Does the Google CDN support any kind of cross-origin request, like JSONP or CORS? Could you show me an example of how to grab the above file?

The above file is part of Dojo, but I am fine with using any other library or plain JavaScript. The only constraint is to grab the file from the Google CDN.


Solution

  • Based on the (lack of) information I got, the Google CDN doesn't support any kind of cross-domain access like JSONP or CORS. It means that the only way to consume the CDN .json files is through a server proxy.

    For client side JavaScript I'll have to store a local copy of the file.