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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:06:25+00:00 2026-05-27T12:06:25+00:00

In my application after getting my application Authorized by Facebook I get all their

  • 0

In my application after getting my application Authorized by Facebook I get all their friends info which is returned in an array.

I sort this array in order of the friends whose birthday is closest to the current date.(code not shown for this)

I want to display the information for 20 friends at a time as some users may have hundreds of friends.

Currently I am putting all of the friends on the page at one time.

Here is the code I was using to loop through the entire array and put the info on the page

$.each(json.data,function(i,fb){

                  var pic_url = "http://graph.facebook.com/"+fb.id+"/picture";
                  json_details = {name: fb.name, provider_user_id: fb.id, birthday: fb.birthday, provider_name : 'Facebook' }; 
                  var celebrant_details = escape(JSON.stringify(json_details) );
                  html += "<form id='new_celebration"+fb.id+"' method='post' action='/celebrations' accept-charset='UTF-8'>";
                  html += "<input type='hidden' id='friend' value='"+celebrant_details +"'  name='celebrant_details'  />"
                  html += "<input type='hidden' id='manager' value='"+manager_details +"'  name='manager_details' />"

                  html += "<li>" + fb.name + "</li>";
                  if(fb.birthday != null){  html += "<li>" + fb.birthday + "</li>"; } //don't show if don't have a birthday
                  html += "<li><img src="+pic_url+" /></li>";       
                  html += "<input class='button-mini-subtle submit' type='submit' value='select' alt='select'  >";    
                  html += "</form>";

                });//.each loop

I am a NOOB so would appreciate some guidance.

I want to give the users a button they can click to display more users from the array.
So I know I need to create some kind of a function call and I need to know where I am in the array.

How can I get this kind of behavior?

  • 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-27T12:06:25+00:00Added an answer on May 27, 2026 at 12:06 pm

    You can use a extra index variable that will hold current index in your array or have the index stored as the jQuery .data(). Then you can use Array.slice() to get the subarray.

    Here is the simplified example using .data(). You have to adapt it to your data structure and required HTML output – that was not your question :).

    // display our initial list
    displayNext();
    
    $("#next").click(function() {
      // display next elements
      displayNext();
    });
    
    function displayNext() {
      // get the list element
      var list = $('#list');
    
      // get index stored as a data on the list, if it doesn't exist then assign 0
      var index = list.data('index') % arr.length || 0;
    
      // save next index - for next call
      list.data('index', index + 20);
    
      // 1) get 20 elements from array - starting from index, using Array.slice()
      // 2) map them to array of li strings
      // 3) join the array into a single string and set it as a HTML content of list
      list.html($.map(arr.slice(index, index + 20), function(val) {
        return '<li id=' + val.id + '>' + val.name + '</li>';
      }).join(''));
    }
    

    HERE is the code.

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

Sidebar

Related Questions

I get this error when debugging my ASP.NET web application after I trigger an
Hello all in my iphone application after sending login xml request am getting following
I'm getting a System.NullReferenceException when my application starts up (after a small login screen)
I'm getting an error when my application starts. It appears to be after it's
I've been tasked with debugging a Java (J2SE) application which after some period of
I have to generate charts on my Web application, and after getting the answer
I have this WCF application which is hosted as a windows service. This service
I am calling a web service from my android client application. After getting response
I am working on facebook application. I am getting the offline access permission from
After getting pretty far along with a jQTouch web application for our website, my

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.