I am grabbing the facebook pages a user admins and displaying them in a select box through the Facebook JS SDK.
What’s the best way to take the array I get back from facebook response.data and iterate so it goes into the select?
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js">
</script>
<script>
FB.init({
appId:'119406238144386', cookie:true,
status:true, xfbml:true
});
FB.api('/me/accounts/', function(response) {
alert(response.data);
});
</script>
<select id="pages"></select>
<fb:login-button perms="manage_pages">Connect to Facebook</fb:login-button>
Facebook returns the object in an object array, so just loop through each one and add a new html object item to the select list.
A full working example without jQuery: