开发者

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开发者_如何学Go 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜