Topic: Pass data from popup to the opening form


I have a form to create a new post and inside this form I have a button that opens a popup form that create a new client.
The popup is a jquery dialog.
I want to do 2 things when I close the popup:
1) save the new client in the database.
2) re-render the select-box in the post form so the new client will be added to the selected box and be selected.

I'm new in the web world (JavaScript, Ajax, rails), so if anyone can please help me and tell me how to do this I'll be so grateful!! (I've spend more then 3 days for searching a solution)

BTW, I'm using rails 3.1