JS SDK FB.login() works but pop-up dialog is staying open after logged in-Collection of common programming errors

I am using the JS SDK for Facebook based on the NEW GraphAPI for Auth/Login.

Has anyone had this issue when logging in after FB.login() was called via the JS SDK?

The problem: after I initialize by calling FB.Init() asynchronously (because this all wrapped in a window.fbAsyncInit function) the login pops up; I log in but then that pop-up refreshes to show a white page and the pop-up stays open and does not close…why? I am waiting to check response.session in the FB.login() callback but it seems as though I never get it back because this pop-up seems to just stick there and the process appears to just halt after you’re logged in and I just figured this pop-up would just close and return me the response.session in the callback automatically. Why would that pop-up not go away?

I copied the url from the pop-up after I’m logged in and showing white the following url so it looks like the response is there but then why isn’t that pop-up window closing so my callback can handle the response??


I did notice that when FB.login() is called and the login pop-up comes up, I see this error in FireBug talking about how it doesn’t like the fact that I’m testing over localhost or something I guess:

uncaught exception: [Exception… “Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMLocation.host]” nsresult: “0x80004005 (NS_ERROR_FAILURE)” location: “JS frame :: chrome://smarterwiki/content/smarterwiki.js :: anonymous :: line 1225” data: no]

that error bothers me…I need to figure out why it’s coming up and I bet you I’m not the only one who has seen this when testing locally. I see no info though on troubleshooting this on the net anywhere either on the Facebook forums or elsewhere. I see others have had this issue but no resolution.

So when you implemented yours, did your facebook pop-up just close after the user is logged in or did you need to do something special to finish this process?

Also, I notice if I manually close that pop-up then go to check if that cookie was generated to contain my session, it’s not (the fbs_[yourappid] cookie). So it looks like something ends prematurely here. I’ve got in my init cookie: true so I wonder if this problem were the pop-up dialog is not closing is related to the cookie also not being created client-side on my test PC.

  1. This problem appeared out of nowhere for my site, when facebook made a recent change to its “all.js”.

    In an earlier version of their javascript I had a problem specific to IE, and I copied this little snippet of code from someone’s post on the internet. It seemed cryptic, but solved the problem at the time:

      // http://developers.facebook.com/bugs/204792232920393
      // Hack to fix http://bugs.developers.facebook.net/show_bug.cgi?id=20168 for IE7/8/9.
      FB.UIServer.setLoadedNode = function (a, b) { FB.UIServer._loadedNodes[a.id] = b; };
      FB.UIServer.setActiveNode = function(a, b) { FB.UIServer._active[a.id]=b; };

    It turns out those lines were causing this problem for me. I removed them, and the problem went away. The original bug specific to IE has also been fixed, I believe, in the most recent “all.js”.

  2. It seems that you are trying the localhost, can you try it with the public url.

    I already faced this problem. But I solved it by configuring the canvas url in application as the public url (example. www.something.com/test/).