7

I'm trying to use a facebook UI request dialog for selecting a friend. This works absolutely fine in safari and Chrome but in firefox and IE11 (Not tested lower versions yet) it continuously hangs with the loading animation.

function pickFriend(ev)
{
     FB.ui(
     {
          method: "apprequests",
          message: "Choose a friend.",
          max_recipients: 1,
          title:"Invite a friend"
     },sendMessage);
     ev.preventDefault();
}

$("#element").click(pickFriend);

I then tried calling the function directly in the console to ensure that it wasn't my implementation that was the problem, and i got the same result with it hanging with the loading animation. I then tried different display options and i can get it too work in popup mode but for me this is not very elegant and i would far prefer it to work in iframe mode the same way it does in safari and chrome.

Has anyone else been experiencing this issue? If so is there a reason for this and is ther a fix?

I'm thinking that this maybe something that is entirely down to facebook to fix which would leave no other option but to run in popup mode if i want to keep browser compatibility.

Lightbulb1
  • 12,882
  • 6
  • 22
  • 23
  • Yes, others are having the same issue. I placed a bounty on this question (just cause I saw that one first), but it is exactly the same issue http://stackoverflow.com/questions/22388607/method-fb-ui-loads-forever-when-called-on-firefox-and-internet-explorer – Slav Mar 18 '14 at 19:46
  • Thankyou. For now im just making do with the popup display type. It would be good to run in an iframe though. – Lightbulb1 Mar 18 '14 at 19:48
  • Actually, found the answer in here http://stackoverflow.com/questions/22389148/facebook-request-prompt-not-loading-for-game-in-firefox . It is a confirmed FB bug https://developers.facebook.com/x/bugs/733458870047972/ – Slav Mar 18 '14 at 19:50
  • I hope it gets fixed soon. I guess this is the problem relying on a third party. I should of made or used a javascript friend picker. I don't have time now though. – Lightbulb1 Mar 18 '14 at 20:17
  • In our case, we were explicitly stating `display:"iframe"`. After removing that, everything worked fine – Slav Mar 18 '14 at 20:29

1 Answers1

1

In IE11 (and node) the javascript engine can get hung up on long operations. The recommended work around is utilizing "setImmediate", so for your example:

function pickFriend(ev)
{
 ev.preventDefault();

 setImmediate(FB.ui
    , {
       method: "apprequests",
       message: "Choose a friend.",
       max_recipients: 1,
       title:"Invite a friend"
    }
    , sendMessage
 );
}

$("#element").click(pickFriend);

Also, make sure your "sendMessage" variable is scoped properly and not undefined or null.

Syntax

var immediateID = setImmediate(func, [param1, param2, ...]);
var immediateID = setImmediate(func);

Reference: https://developer.mozilla.org/en-US/docs/Web/API/Window.setImmediate

lucnhmeat
  • 11
  • 2
  • Thanks for your response. The project where this was required has been and gone. I'll try and dig it up and test this at some point though. Its an interesting solusion. I don't really know what setImmediate does but i've already established that it issn't supported in all browsers yet so I'm wondering how you could use this and support everything? – Lightbulb1 Jun 27 '14 at 09:27