Facebook javascript application unreliable execution

I have made a facebook application in javascript. When I load it sometimes the facebook api is called sometimes it is not. I am not able to figure out why? I am not able to call any facebook function for that time. If I reload the page the script works then sometimes. The scenario is worse safari where I have to reload multiple time to get the script working. BUt sometimes it just works as I load it can't figure out why.

My facebook application link

I have tried cleaning up cache and everything of the browsers but still the unreliable nature of the script exists


Given the intermittent nature of your issue the first thing i would try is move function fbLogin to below your button just before the closing body tag. The reason for doing this is to make sure your code will execute after the dom is ready.

<script type="text/javascript">
    function fbLogin() {
        FB.login(function(response) {
            if (response.session) {
                //user is logged in, reload page
            } else {
                // user is not logged in
        }, {scope:'user_groups,publish_actions,offline_access'});

As you are using jQuery you could also leave your function where it is and simply wrap your code in the function ready http://api.jquery.com/ready/

    function fbLogin() {

Need Your Help

"Illegal characters in path." Visual Studio WinForm Design View

winforms visual-studio-2008 mvp

I am putting together a lightweight MVP pattern for a WinForms project. Everything compiles and runs fine. However when I attempt to open the WinForm in design mode in Visual Studio I get a "Ille...

Replacing text after node

xslt replace

I am trying to remove the "Hide this data" from this XML which is proceeded with the qualifier type="noView"