0
我有一個畫布Facebook應用程序,我有所有的用戶朋友在JS數組,我想要顯示用戶朋友圖片+名稱一個接一個,點擊NEXT按鈕後,我寫的代碼不工作:Facebook應用程序FBJS幫助使用setInnerXHTML +數組
<script>
<!--
var friends = new Array(); //Friends Array
<?php
for($i=0; $i<= $limit; $i++) //Add to JS array all friends id's from PHP array
{
echo 'friends['.$i.'] = '.$appfriends[$i][uid].';';
}
?>
/*
I'm passing to this function the first Array --> 0 to increment it each time Next Friend clicked, and show the next friend picture then change Next Friend URL with the next friend Array Key
*/
function get_friends(id){
var fid;
fid = id++;
var fid_img = "<img src=\"https://graph.facebook.com/"+friends[fid]+"/picture\"/>";
var fid_link = "<a href=\"#\" onclick=\"get_friends("+fid+"); return false;\">Next Friend</a>";
//Changing Friend Image
document.getElementById('show_friends').setInnerXHTML(fid_img);
//Changing Next Friend URL
document.getElementById('next_friend').setInnerXHTML(fid_link);
}
//-->
</script>
<div id="show_friends">
<img src="https://graph.facebook.com/<?php echo $appfriends[0][uid];?>/picture"/>
</div>
<br>
<span id="next_friend"><a href="#" onclick="get_friends(0); return false;">Next Friend</a></span>
FBJS文件:http://developers.facebook.com/docs/fbjs
對不起我的英語不好。 在此先感謝!