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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:33:53+00:00 2026-05-22T19:33:53+00:00

Hopefully there is an easy way to do this and my Javascript skills are

  • 0

Hopefully there is an easy way to do this and my Javascript skills are just lacking. I am wanting to call a function that will get some Facebook posts, add them to an array and return to use elsewhere. Current code is below.

function GetFaceBookStream(name, max) {
    FB.init({ apiKey: 'removed for post' });
    var lastDate = '2011-04-29Z00:00:00';
    var faceBookArray = [];
    var faceBookString;        

    FB.api("/" + name + "/feed", { limit: max, since: lastDate }, function (response) {
        var sb = string_buffer();

        for (var i = 0; i < response.data.length; i++) {
            var post = response.data[i];

            sb.append("<li class='facebook'>");
            sb.append("<img alt=\"Facebook\" src='Images\\Carousel\\fbIcon.png\' />");
            sb.append("<h4>FACEBOOK</h4>\n");
            sb.append("<div class=\"from-name\"><a href=\"http://www.facebook.com/#!/profile.php?id=" + post.from.id + "\">" + post.from.name + "</a></div>");
            sb.append("<div class=\"time\">" + post.created_time + "</div>");
            if (post.message != undefined) {
                sb.append("<div class=\"message\">" + post.message + "</div>");
            }

            sb.append("</li>stringSplitMarker");
        }

        faceBookString = sb.toString();
        faceBookArray = faceBookString.split('stringSplitMarker');            
    });

   return faceBookArray;
}

I realize this set up won’t work due to variable scope in Javascript, but this is basically what I’m trying to achieve. Any help will be greatly appreciated!

  • 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-22T19:33:54+00:00Added an answer on May 22, 2026 at 7:33 pm

    You’re making an asynchronous AJAX request.
    The callback only runs after your code finishes.

    You need to pass the data back using a callback.

    For example:

    function GetFaceBookStream(name, max, callback) {
        ...
        FB.api(..., function(response) { 
            ...
            callback(something, else);
        });
    }
    

    You can call the function by supplying a callback to receive the response:

    GetFaceBookStream(name, max, function(param1, param2) {
        //This code runs later and can use the response.
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This will hopefully be an easy one, but I'm lacking the skills! <select name=search_category
Hopefully this is an easy one. Is there a way to test for an
Is there any chance to get a easy way to sync data, in this
I'm new to jQuery so hopefully there is an easy answer to this. I
Now there is a subject that could be taken many ways. Hopefully I will
Hopefully this should be an easy answer for someone out there (and possibly a
Hopefully this has an easy answer I just haven't been able to find: I
Hopefully this will be an easy one to answer. I created a class in
Ok hopefully this is an easy question: I have a main viewcontroller that is
This is hopefully a quick/easy one. I know a way to work around 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.