简体   繁体   中英

How to stop redirection after FB.login() for Facebook application?

So, the mechanism is simple. I use Facebook JS SDK's FB.login() to let a user log in to my application. After the user clicked allowed, I wanted to call ajax to update the content of the page.

However, the page is refreshed as soon as the pop up is gone and my ajax call was also aborted. How do I prevent FB from refreshing my page?

You can see the abstract of the code at http://jsfiddle.net/mmhan/7BGmf/3/

HH.fb_userConnected() is the ajax call. The documentation also doesn't describe any additional parameters for FB.Login() function

Lemme know if anymore info was needed.

  • mmhan

Try subscribing to the auth.login event, like this

FB.Event.subscribe('auth.login', function() {
  // if you already have this, it's why the page refreshes in the first place
  // window.location.reload();
});

You can issue the ajax call there. Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM