Validation and Re-display with Ajax

This might be a simple question but Ive had to work around it in both Rails and PHP. Wondering if there is a standard way to do this.

I have a form where you have a Department Dropdown and associated Activities for that Department. When you select a department from the dropdown, I use ajax to pull the activities for that department and display it as another drop down. When I submit this form (that contains other text fields) and if validation fails on that, I would need to re-display the whole page and also indicate possible errors. This is all handled by Rails except for fields that I fetched using ajax (activities in the above example). Because the activities is only populated when I onchange the department field, the dropdown for activities is empty when the page is re-displayed.

Ive worked around this by checking for the department_id in the controller and fetching the activities array during re-display, but as you can see, this will get complex when you have a few drop downs where each depend on the one above(for e.g. a Country/State/City/Area type of dropdown).

Is there a standard pattern for solving this problem?

Thanks Raja