I'm using inline-edit to update text in the database with AJAX. This is basically the process, pretty usual stuff:
- text is not editable
- I click the text, it becomes editable
- I type the new text
- then click to send the updated text to the database
- then return the text to non-editable format
My question is when should I update the interface with the new data? Should I update it immediately before the ajax call, or should I wait for the update response to return from the database?
My concern:
- If I don't update the interface immediately and wait to get the response from the database, then I've lost the asynchronous benefit that comes with ajax.
- But if I update it immediately, then if the database response has an error, I somehow have to track the change I already made, and reverse it, which is a lot more work.
So how is this sort of thing usually done?