getting json from external source in javascript

前端 未结 3 1541
日久生厌
日久生厌 2021-01-27 03:43

Json issues with javascript and jquery. Trying to load some JSON using javascript.

I have it working using:

See it here: http://jsfiddle.net/5pjha/789/



        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-27 04:28

    I believe the issue is down to whether or not the servers you are requesting your JSON from have cross-origin resource sharing (CORS) enabled.

    you can see in the headers from the google service that they set Access-Control-Allow-Origin:* This is not the case for teh other URL's you list.

    To get around this you will need some form of proxy so that you can request from a server either on the same domain or a server that enables CORS.

提交回复
热议问题