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

  • Home
  • SEARCH
  • 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 3599124
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:19:44+00:00 2026-05-18T20:19:44+00:00

I am using the following functions: function loop_perms(permissions) { …. call check_perm here…. }

  • 0

I am using the following functions:

function loop_perms(permissions) {
.... call check_perm here....
}
function check_perm(perm) {
        var result;
        FB.api(
         {
            method: 'users.hasAppPermission',
            ext_perm: perm
         }, function(response) {
            result = response;
         });
         return result;
    }

Now, the issue is that I am getting an undefined from the result of check_perm whereas in the Firebug console, I can see that response has a value of 0 or 1 (depending on perm)

Anyone knows what I am doing wrong? I am guessing it has something to do with the fact that i am trying to capture the value of a variable inside a callback.

Regards
Nikhil Gupta.

  • 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-05-18T20:19:44+00:00Added an answer on May 18, 2026 at 8:19 pm

    I assume the Facebook API is asynchronous. So at the time return result is executed, the callback was not called yet. You have to provide a callback from the calling function:

    function check_perm(perm, callback) {
        var result;
        FB.api(
         {
            method: 'users.hasAppPermission',
            ext_perm: perm
         }, callback);
    }
    

    and

    function loop_perms(permissions) {
        check_perm(whatever here, function(result) {
            // do something with result
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following functions: function loop_perms(permissions) { .... call check_perm here.... }
I'm using the following functions: # The epoch used in the datetime API. EPOCH
I'm formulating an Ajax request using prototype in the following method: function updateServerStep(stepNumber){ alert(updating
I am using the following function to loop through a couple of open CDB
I am using the following function to create a System.ServiceModel.EndpointAddress when connecting to a
I'm using the following function that changes a calendar selection at a set time
I am using the following functions for writing and reading 4098 floating point numbers
What are the sql exceptions will thrown by using the following function: Read Update
I am creating several image dynamically using the following code: function refresh_gallery(galleryidentifier, albumid) {
Using the following JQuery/AJAX function I'm calling a partial view when an option is

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.