0
我有一些3種方法。Javascript異步
login();
isLogin();
reply();
function isLogin(){
FB.getLoginStatus(function(response) {
if (response.session) {
// logged in and connected user, someone you know
} else {
// no user session available, someone you dont know
}
});
}
function login(){
FB.login(function(response) {
if (response.session) {
// user successfully logged in
} else {
// user cancelled login
}
});
}
function reply(){
var body = 'Reading Connect JS documentation';
FB.api('/me/feed', 'post', { body: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response);
}
});
}
我需要,當用戶想要回複評論,然後執行回覆方法。在執行回覆方法之前,應該測試用戶是否登錄,如果用戶沒有登錄,則執行登錄方法並再次調用回覆方法。我怎樣才能實現這個任務提前
感謝
4米的空間。 'ctr-k'作爲選擇。不知道那些'>'是什麼,所以我把它們留在......你可能想要刪除它們。 – 2010-10-20 22:35:46
@Peter:'>'是爲了引用,可能是爲了模仿源代碼格式。 – 2010-10-20 22:40:51