I'm trying to do what is supposed to be fairly simple with facebook connect, but having no luck.
When a user logs in, I want to show that users details (refreshed without reloading the page), and when the user logs out, I need to go back to a logged in state.
The code I have is
function update_user_box(){ jQuery('span#loggedin').html(''); jQuery('span#fbLogin, ul#otherLogin').hide(); jQuery('div#popForecast li.otherLogin, ul.showList li.otherLogin').remove(); jQuery('span#logged').text('1'); FB.XFBML.Host.parseDomTree(); } function fbLogout(){ FB.Connect.logout(); jQuery('span#fbLogin').show(); jQuery('span#loggedin').empty(); jQuery('span#logged').text('0'); } FB.init('c0529b8c11709f2317ae643d854e3866', 'xd_receiver.htm'); FB.ensureInit(function(){ FB.Connect.ifUserConnected(update_user_box); });
I can log the user in and out, but nothing else changes. I can't even trigger an alert from my functions.
For some reason the html I'm using won't display within the pre tags, however, on reloading the page, the user is displayed (or not as it should), so it is just not being triggered directly from the javascript functions. But refreshing the page launches the correct function.
The error I get in firebug is 'fbLogout undefined', but clearly it is defined. Does it matter where I define it? Currently all of the javascript/jquery is in the head within script tags. Though I've tried moving it down into the page and didn't have luck their either.