Comment créer une variable dynamique en js?
Je cherche une solution, pour générer plusieurs variables à affecter dans ma méthode ajax post (jquery), un peu comme dans php... J'ai pas trouvé de solution concluante. Voici le code en question :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| // partie : photos ajax
// En cas de soumission du formulaire des photos
//
$('#formPhotos').submit(function() {
var tab_photos = [];
var nombrePhotos = inc;
for (indice=1; indice<=nombrePhotos; indice++ ) {
// partie critique
var variable = 'photo_'+indice = $(this).find("select[name=photo_"+indice+"]").val();
}
$.post("ajax_ajouterPhotos.php", {photo_:variable}, function(data) {
// ...
});
}); |