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 952481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:54:02+00:00 2026-05-15T23:54:02+00:00

I swear this was working last night which was why I was able to

  • 0

I swear this was working last night which was why I was able to get to bed at 1am ;). I come into work this morning and now it never gets to the callback of FB.api. The FB.api is an async Facebook JS call…but regardless this was working fine last night and I don’t think it’s a facebook server (end point) issue.

            function BindAlbumAndPhotoData()
            {
                GetAllAlbums(userID, accessToken, function(aAlbums) 
                {
                    alert("we're back and should have data");

                    if (aAlbums === null || aAlbums === undefined) {
                        alert("array is empty");
                        return false;
                    }

                    var defaultAlbumID = aAlbums[0].id;

                    alert(" defaultAlbumID: " + defaultAlbumID);

                 });
            };


function GetAllAlbums(userID, accessToken, callbackFunctionSuccess)
{
    var aAlbums = []; // array
    var uri = "/" + userID + "/albums?access_token=" + accessToken;

    alert("uri: " + uri);

    FB.api(uri, function (response) 
    {
        alert("inside FB.api");
        // check for a valid response
        if (!response || response.error) 
        {
            alert("error occured");
            return;
        }

        for (var i = 0, l = response.data.length; i < l; i++) {
            alert("Album #: " + i + "\r\n" +
                  "response.data[i].id: " + response.data[i].id + "\r\n" +
                  "response.data[i].name: " + response.data[i].name + "\r\n" +
                  "response.data[i].count: " + response.data[i].count + "\r\n" +
                  "response.data[i].link: " + response.data[i].link
                  );

            aAlbums[i] = new Album(
                                                    response.data[i].id,
                                                    response.data[i].name,
                                                    response.data[i].count,
                                                    response.data[i].link
                                                   );

            alert("aAlbums[" + i + "].id : " + aAlbums[i].id);
        }

        alert("about to pass back the array to the callback function");

        callbackFunctionSuccess(aAlbums);
    });
}

So it gets to the alert for the uri but never hits the first alert inside the FB.api callback..meaning it never hits alert(“inside FB.api”); and I have no clue why.

UPDATED

Looks like all my api calls are being aborted. Not sure what would abort it (the FB server?):

alt text http://elbalazo.net/post/abortedcalls.jpg

UPDATED #2

Ok looks like that abort is just saying the Http Request is done. If I right-click that abort line in Firebug and select “Open in new tab” it’s showing the HttpResponse data…but I think that’s because it’s sending a manual request when I do this just like you would copy and paste this request url into a browser manually…

On the other hand if I right-click that abort line and choose “Copy Response Headers” I get nothing. Also when I check this out in Chrome, I see the Request Header but don’t see any Response Header.

So still don’t get then why it’s not entering the callback then if I am getting back data from the FB.api call

UPDATED #3

Ok, got this working again. I had the call to the callback method inside my FB.api’s callback. So it was bombing out.

function BindFacebookAlbumAndPhotoData()
{
GetAllFacebookAlbums(userID, accessToken, function(aAlbums) 
{

    if (aAlbums === null || aAlbums === undefined) {
    alert("array is empty");
    return false;
    }

    // Set the default albumID
    var defaultAlbumID = aAlbums[0].id;

};

function GetAllAlbums(userID, accessToken, callbackFunctionSuccess)
{
var aAlbums = []; // array
var uri = “/” + userID + “/albums?access_token=” + accessToken;

//alert("uri: " + uri);

FB.api(uri, function (response) {
    alert("inside FB.api");

    // check for a valid response
    if (!response || response.error) {
        alert("error occured");
        return;
    }

    for (var i = 0, l = response.data.length; i < l; i++) {
        alert("Album #: " + i + "\r\n" +
              "response.data[i].id: " + response.data[i].id + "\r\n" +
              "response.data[i].name: " + response.data[i].name + "\r\n" +
              "response.data[i].count: " + response.data[i].count + "\r\n" +
              "response.data[i].link: " + response.data[i].link
              );

        aAlbums[i] = new FacebookAlbum(
                                        response.data[i].id,
                                        response.data[i].name,
                                        response.data[i].count,
                                        response.data[i].link
                                       );

        alert("aAlbums[" + i + "].id : " + aAlbums[i].id);
    }
});

    alert("about to pass back the array to the callback function");
    callbackFunctionSuccess(aAlbums);

}

  • 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-15T23:54:03+00:00Added an answer on May 15, 2026 at 11:54 pm

    Hmm try the following

    function GetAllAlbums(userID, accessToken, callbackFunctionSuccess)
    {
        var aAlbums = []; // array
        var uri = "/" + userID + "/albums?access_token=" + accessToken;
    
        alert("uri: " + uri);
    
        FB.api(uri,GetAllAlbumsCallback);
    }
    
    function GetAllAlbumsCallback(Data)
    {
        alert("inside FB.api");
            // check for a valid response
            if (!Data || Data.error) 
            {
                return;
            }
    
            for (var i = 0, l = Data.data.length; i < l; i++)
            {
                aAlbums[i] = new Album(
                    Data.data[i].id,
                    Data.data[i].name,
                    Data.data[i].count,
                    Data.data[i].link
                );
    
                if (aAlbums === null || aAlbums === undefined)
                {
                    alert("array is empty");
                    return false;
                }
                var defaultAlbumID = aAlbums[0].id;
                alert(" defaultAlbumID: " + defaultAlbumID);
            }
    }
    

    Just try separate the callbacks from being anonymous, sometimes the there can be scope issues :/

    separating them should give them a global scope and generally less error prone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I swear this script worked fine last night but can't get it to work
I could swear this was working yesterday. Now however the code below destroys the
I could swear this was working the other day: var resultSet = (from o
I swear, I have this exact thing working on another page. I'm such a
I swear this used to work, but it's not in this case. I'm trying
I swear the following code used to work, even in IE7 but now i
I had this almost working several hours ago, but I can't seem to get
I swear i couldn't find a simple working solution for this. On a form
This should be simple, and I swear it was working an hour ago. I
I swear this assignment will be the end of me, I've been researching this

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.