admin管理员组文章数量:1315360
I am looking forward to create a javascript API that contains most of the functions that facebook Javascript API provides.
FB.api
FB.init
FB.logout
FB.getLoginStatus
FB.login
FB.ui
I can just embed script tag in remote website and need to do all the ajax calls from that page to my server. I am creating an architecture and needs someone help in finishing it with his/her excellent ideas.
I am looking forward to create a javascript API that contains most of the functions that facebook Javascript API provides.
FB.api
FB.init
FB.logout
FB.getLoginStatus
FB.login
FB.ui
I can just embed script tag in remote website and need to do all the ajax calls from that page to my server. I am creating an architecture and needs someone help in finishing it with his/her excellent ideas.
Share Improve this question asked Nov 2, 2010 at 20:26 Ayaz AlaviAyaz Alavi 4,8358 gold badges51 silver badges68 bronze badges 4- 1 what exactly is your question? – pex Commented Nov 2, 2010 at 20:29
- why re-create something that's already been done by professional programmers? – jrn.ak Commented Nov 2, 2010 at 20:45
- well I need to create javascript API for my web application – Ayaz Alavi Commented Nov 2, 2010 at 21:02
- @pex I need to know how facebook does cross domain ajax calls. If you open any website using facebook javascript SDK then you can see that on firebug how easily they are doing ajax calls to their servers. – Ayaz Alavi Commented Nov 2, 2010 at 21:04
3 Answers
Reset to default 5Take a look at https://github./facebook/facebook-js-sdk/blob/deprecated/src/core/xd.js
They use a bination of rpc workarounds (with a relay file), Flash Local Connection and postMessage, whichever is supported by the browser.
You can also take a look at Cross Site XmlHttpRequest(CORS). From your question, it seems that you can control your server that will respond to the requests. In that case, you can tune the headers to receive requests and respond to cross domain requests.
Then, your embedded script will be able to talk to your server from any web page if you configure the request header in the requests that you make from your embedded script.
I like this method as it is extremely easy to implement. Watch out for browser support though!
They are using JSONP. It's widely used and is supported by javascript frameworks like JQuery.
本文标签: javascripthow facebook does cross domain ajax callStack Overflow
版权声明:本文标题:javascript - how facebook does cross domain ajax call? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741950990a2406705.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论