2010-12-03 4 views
0

J'ai une application de toile Facebook, j'ai tous les amis utilisateurs dans le tableau JS, et je veux montrer aux amis de l'utilisateur image + nom après un, après avoir cliqué sur le bouton SUIVANT, le code j'ai écrit ne fonctionne pas:Facebook Application FBJS aide en utilisant setInnerXHTML + tableau

<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 Documentation: http://developers.facebook.com/docs/fbjs

Désolé pour mon mauvais anglais. Merci d'avance!

Répondre

2

Je résolu le problème, pour créer un tableau à l'aide FBJS vous devez utiliser

<script> 
<!-- 
var arrayname = []; 

//instead of 

var arrayname = new Array; 
//--> 
</script> 
Questions connexes