Question

J'essaie depuis environ une journée maintenant pour faire fonctionner cette méthode.

J'essaye d'utiliser la jQuery .each() Fonction pour effectuer une action pour chaque élément dans un tableau donné.

Le tableau vient d'un .post() demande

$(document).ready(function() {
$.post("assets/scripts/chat/load_convos.php",{}, function(data) {

//perform the .each() function

});

})

Le tableau est renvoyé dans ce format [56,98.24,46] via le fichier php load_convos.php

C'est le fichier PHP

$get_convos = mysql_query("SELECT status, partner_user_id FROM chat_convos WHERE user_id = '$user_id'");
$following_user_id = '';
$uids = array();
while($row = mysql_fetch_assoc($get_convos)){
    array_push($uids, $row['partner_user_id']);
}
$following_user_id = implode(',', $uids);
echo "[$following_user_id]";

Honnêtement, je ne vois pas ce que je fais mal ...

======== Edit ==========

C'est ce que j'ai fait jusqu'à présent

$.each(data, function(value) { 
  alert(value); 
});

Pas de solution correcte

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top