Using AJAX to dynamically populate a dropdown menu

I am using Yii 1.x and I have a form which has a dropdown menu called ‘Classes’, each class has a number of students (all this info is stored within a database).

e.g Class ‘A’ has students ‘John’ & ‘Lee’, Class B has students ‘Paul’ & ‘Gemma’.

Depending on which class is selected from the initial ‘Class’ dropdown menu I want another dropdown populated via AJAX with their related students.

Can anyone suggest the best way to go about this using Yii/renderPartial - any advice would be appreciated

I would just create a separate ajax action that specifically accepts a value from your Classes dropdown (like the PK), pull all related students then return the results in a json string. I would then parse that and manually rebuild the second dropdown