In my application, after receiving my Facebook Authorized application, I receive all the information of my friends, which is returned in an array.
I sort this array in order of friends whose birthday is close to the current date (code not shown for this)
I want to display information for 20 friends at a time, as some users may have hundreds of friends.
Currently, I put all my friends on the page at a time.
Here is the code I used to iterate over the entire array and put the information 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 NOOB, so I would appreciate some recommendations.
I want to give users a button that they can click to display more users from the array. So I know that I need to create some kind of function call, and I need to know where I am in the array.
How can I get this behavior?
chell source share