简体   繁体   中英

XML and JSON feeds in javascript. Access allowed, only sometimes

Something weird i've noticed with accessing XML and JSON feeds using javascirpt is that access is often denied (for security reasons I guess...).

Chrome says: XMLHttpRequest cannot load graph.facebook.com/100001263589003/feed. Origin fiddle.jshell.net is not allowed by Access-Control-Allow-Origin.

As you can see in this script: http://jsfiddle.net/sikko/RvQVX/2/

graph.facebook.com/100001263589003/feed?callback=? will work

and

graph.facebook.com/100001263589003/feed will not work

Why ? and how can I figure it out, that an argument such as callback for facebook is provided by the API ?

Why ?

Your JS library is probably switching to use JSON-P (cross domain hack that requires the co-operation of the target site) instead of XMLHttpRequest (subject to the same origin policy) when you include callback=? in the URI.

and how can I figure it out, that an argument such as callback for facebook is provided by the API ?

Read the documentation for the API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM