$ajax get, récupérer id/class d'une image dans une boucle while PHP
Bonjour,
Voilà le cas :
1. Je génère une liste d'images (photos contacts) en PHP à partir de ma BD MySQL.
2. Je peux cliquer dessus afin d'obtenir le profil complet, j'utilise Jquery avec $ajax.
3. Tout marche très bien sauf que c'est toujours l'id de ma première image qui est passé en paramètre... ;(
1. PHP - Liste d'images
Code:
1 2 3 4 5 6
|
<?php while($row = mysql_fetch_array($res)){ ?>
<a href="#" id="<?php echo $row['id_inscription'];?>" class="ProfilMini">
<img src="<?php echo $row['miniature_path_moyen'];?>" title="" alt="" />
</a>
<?php } ?> |
2. Jquery - $ajax
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
<script type="text/javascript">
$(document).ready(function(){
function afficherProfile(){
var annonce = $('.ProfilMini').attr('id');
$.ajax({
url: "rechercher-simple-afficher-profile1.php",
type: "GET",
data: 'annonce_id='+annonce,
dataType: "html",
contentType : "application/x-www-form-urlencoded; charset=ISO-8859-1",
complete: function(data){
$("#afficherProfile").show();
$("#afficherProfile").empty();
$("#afficherProfile").append(data.responseText);
}
});
}
$('.ProfilMini').click( function(event){ afficherProfile(); });
});
</script> |
Quelqu'un pourrait-il m'aider ?? Je planche dessus depuis 1 semaine et toujours rien ... merci d'avance
Rico