这是Facebook Developers网站的一个片段。这是什么Javascript代码?解释
<div id="info"></div>
<script>
var
info = document.getElementById('info'),
update = function(response) {
if (!response.session) {
info.innerHTML = '<em>You must login using the controls at the top.</em>';
return;
}
FB.api(
{
method: 'fql.query',
query: 'SELECT name, pic_square FROM user WHERE uid=' + response.session.uid
},
function(response) {
info.innerHTML = (
'<img src="' + response[0].pic_square + '"> ' +
response[0].name
);
}
);
};
// update on login, logout, and once on page load
FB.Event.subscribe('auth.login', update);
FB.Event.subscribe('auth.logout', update);
FB.getLoginStatus(update);
</script>
以上,可以请你告诉我什么是更新变量,它的类型和工作原理,并分配的结束位置,谁调用这个函数?
其次,调用FB.api的第一个参数是什么?它是什么类型的对象?我相信第二个是回调函数吧?
什么? '{method:'fql.query',query:'SELECT name,pic_square FROM user WHERE uid ='+ response.session.uid}'不是一个字符串... – 2010-06-26 15:55:00
它不仅仅是一个字符串,它的JSON。 – 2010-06-26 16:00:48
对不起,以为他的意思是'fql.query' - 继续。 – 2010-06-26 16:41:10