Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9060663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:17:15+00:00 2026-06-16T15:17:15+00:00

To begin my page i do a check with facebook to get the login

  • 0

To begin my page i do a check with facebook to get the login status of the user. I then create a namespace within the window object for use in other javascript files. Before I load any other javascript i need this namespace to be created, or else it will be undefined when i try to access it. Sometimes it completes first, and sometimes it does not. How can i make sure that it happens correctly every time?

.
.
.
        FB.getLoginStatus(function(response) {
          // store data on the user inside of a namespace 
          // inside of the window object so it can be accessed
          // from anywhere. Use this like '$_SESSION'
          console.log('doing it');
          window.easyUserData = {
            fbRespose: response,
            site: <?php echo '"'.$site.'"'; ?>
          };
        })
      };

      (function(d) {
        var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        ref.parentNode.insertBefore(js, ref);
      }(document))
    </script>
    <!-- Load the script "js/main.js" as our entry point for require -->
    <script data-main="js/main" src="lib/Require/require.js"></script>

specifically, i need the:

<script data-main="js/main" src="lib/Require/require.js"></script>

to not happen until the facebook function is complete

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:17:17+00:00Added an answer on June 16, 2026 at 3:17 pm

    Move the code relying on the namespace into the Facebook callback. If it’s the <script data-main="js/main" src="lib/Require/require.js"></script>, create the script element dynamically:

      // ...
    
      FB.getLoginStatus(function(response) {
        // store data on the user inside of a namespace 
        // inside of the window object so it can be accessed
        // from anywhere. Use this like '$_SESSION'
        console.log('doing it');
        window.easyUserData = {
          fbRespose: response,
          site: <?php echo '"'.$site.'"'; ?>
        };
    
        // Create the script element when ready
        var script = document.createElement('script');
        script.setAttribute("data-main", "js/main");
        script.src = "lib/Require/require.js";
        document.getElementsByTagName('script')[0].parentNode.appendChild(script);
        // Or instead of `document.getElementsByTagName('script')[0].parentNode`
        // you can use `document.documentElement` or `document.getElementsByTagName('head')[0]
        // or a few others
      })
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I begin in GUI with Tkinter with Python. I'm trying to create a graphical
I have Drop Down List with check box in my asp.net page. in that
Is it possible to check the position of ScrollBar in wpLicense Page in Inno
When a user tries to access a page in the administration controllers (mostly CRUD
I have coded a php script that is used to check the status of
What is the best part of the page lifecycle to check if a condition
So I have a home page where a user can log in. Once they
i was trying to get my check box to output Korting is ... %
I have the below stored procedure to check the user name availability DELIMITER $$;
Please have a look at this page www.pixeli.ca/issue. I have begun making a page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.