简体   繁体   English

在Facebook应用程序的FB.login()之后如何停止重定向?

[英]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. 我使用Facebook JS SDK的FB.login()来让用户登录到我的应用程序。 After the user clicked allowed, I wanted to call ajax to update the content of the page. 用户单击允许后,我想调用ajax来更新页面的内容。

However, the page is refreshed as soon as the pop up is gone and my ajax call was also aborted. 但是,弹出窗口消失后页面也将刷新,并且我的ajax调用也被中止。 How do I prevent FB from refreshing my page? 如何防止FB刷新页面?

You can see the abstract of the code at http://jsfiddle.net/mmhan/7BGmf/3/ 您可以在http://jsfiddle.net/mmhan/7BGmf/3/上查看代码摘要

HH.fb_userConnected() is the ajax call. HH.fb_userConnected()是ajax调用。 The documentation also doesn't describe any additional parameters for FB.Login() function 该文档也没有描述FB.Login()函数的任何其他参数。

Lemme know if anymore info was needed. Lemme知道是否需要更多信息。

  • mmhan han

Try subscribing to the auth.login event, like this 尝试订阅auth.login事件,如下所示

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. 您可以在此处发出ajax调用。 Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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