Store html form on client or server while building?
I have a fairly complex html form enhanced via jquery. It has multiple tabs, within each one things like a html form builder, uploads, descriptions.
There is lots of data, and as the user flicks around the various tabs I'm thinking of posting the data to the server. For example, the form builder, has about 10 properties for each field, as the user flicks between the various fields, an ajax request saves the current values, then loads a new set from the new field clicked on.
When the user hits save, the idea is then on the server all these bits and pieces come together and become the live version (i may store them as a temp version while the user is working away).
So I guess my question is, for complex forms where the same fields are re-used within the one form, does anyone attempt to save all this data 开发者_如何学Pythonlocally and upload it in one hit or do most of you do little ajax post's and compile it all when the final save button is hit?
b
You should do it as a single post, this way the form will still have a way of working with no Javascript. Then you can save intermediate steps to the server, so that in case of any trouble, a lot of user input is not lost.
Much depends on the specifics of your form, but I'd suggest AJAX services to save/load form state, then an actual POST to do the final send.
It might depend on how the object model is designed and validated. Is it one large object? Or an object tree/graph of some sort? If the latter, then maybe partial trees or some of the smaller objects can be persisted on the server and validated easily enough. if it's one big object, then maybe it will be a good idea to keep the data on the page and POST (and validate on the server) in one hit. I'd suggest the 1st option tho - smaller pieces is good everywhere in a design. It will help you debug easier too.
精彩评论