[jQuery] Suggest scenario for pup-up form edit

[jQuery] Suggest scenario for pup-up form edit


Hi,
The scenario is:
On a page there's an area with some details. When user click there a
dialog opens to edit the fields.
User can click Close/Cancel or Save.
If Cancel - dialog gets closed.
If Save -the data gets posted and then one of the 2 scenariouses
happen:
1. Data is valid - dialog is closed. The information on the page is
updated with new data.
2. Data is invalid (validation errors or something) - dialog is
refreshed with all the fields and validation errors.
What exactly I'm interested in are:
1. How to post data from the Dialog to server?
2. What is the better way to post data and handle the result?
$('#dialog').load(url, params) will work to provide validation
errors.
3. Should the server return HTML if there're some validation errors
and JSON with updated data if all was ok?
Thanks,
Dmitriy.