2010-05-18 4 views
2

Je suit genre d'index tout en accédant à des données JSON en utilisant jqueryAutomatiser Accès d'Alpha Index numérique JSON

data.rows[0].student_1 
data.rows[0].student_2 
data.rows[0].student_3 and so on... 

Maintenant, je veux automatiser cette chose dans une boucle comme

for(var i=1;i<length;i++) 
{ 
    // so that i can access all student records i.e. student_1, student_2 and so on 
data.rows[0].student_+i; // this doesn't work 

} 

Répondre

1

Utilisation l'accesseur propriété de style tableau:

data.rows[0]["student_"+i];