Facebook的Javascript API第,回调函数? [英] Facebook Javascript API , callback function?
问题描述
我使用 Facebook的Javascript API第
在我的 jQuery Mobile的网站
以进口的专辑
和照片
页
。
I am using Facebooks Javascript API
in my jQuery Mobile Website
in order to import the albums
and photos
of a facebook page
.
它相当容易使用的API:
Its fairly easy to use the API :
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'YOUR_APP_ID', // App ID from the app dashboard
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel file for x-domain comms
status : true, // Check Facebook Login status
xfbml : true // Look for social plugins on the page
});
// Additional initialization code such as adding Event Listeners goes here
FB.api('16907099963/albums', checkForErrorFirst(getAlbums));
};
// Load the SDK asynchronously
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
正如你看到我在这里做对API的调用: FB.api('16907099963 /相册,checkForErrorFirst(getAlbums));
这会给我所有的本页面的专辑。电话是异步
。我需要找到一种方法,能够知道什么时候调用完成。但我真的无法找到任何回调函数
在这里..
As you see i make a call to the API here : FB.api('16907099963/albums',checkForErrorFirst(getAlbums));
which will give me all the albums of this page. The call is asynchronous
. I need to find a way to be able to know when the call has finished. But i really cant find any callback functions
here..
该API可以发现这里
原因我问这个,是我需要添加一个jQuery Mobile的加载窗口小部件,之前我调用API,并使其停止时,专辑已经呈现。在这一个任何想法?
The reason i am asking for this , is that i need to add a jquery mobile "loading" widget , before i call the API and make it stop when the albums have rendered. Any idea on this one?
推荐答案
的 checkForErrorFirst
是回调函数。我想你也缺少页面ID前斜线在 FB.api
。快速sollution如果不能修改 checkForErrorFirst
功能:
The checkForErrorFirst
is the callback function. I think your are also missing a slash before the page ID in FB.api
. Quick sollution if you can't edit the checkForErrorFirst
function:
loader.show();
FB.api('/16907099963/albums', function(result) {
loader.hide();
checkForErrorFirst(getAlbums)(result);
});
这篇关于Facebook的Javascript API第,回调函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!