我使用内线编辑来更新 AJAX 数据库中的文本。 这基本上是一个过程, 非常常见的东西:
- 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
问题在于我何时才能更新与新数据接口的界面? 我应否在Ajax呼叫前马上更新该接口,还是我应等待数据库回复更新回复?
我的关注:
- 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.
这种事通常怎么做到的?