AJAX 和动作预测
我想问问你对此的看法。这是一个理论问题。
我遇到的情况是,我向用户显示一个使用 AJAX 与服务器通信的界面。服务器端语言在这里并不重要。我有一个带有字段的表单,每个字段都是可删除的。如果用户选择一些“删除”复选框并按“更新”,那么我有以下两个选项要做:
选项 1: 删除字段时,使用 JavaScript 立即删除 HTML,并在后台运行 AJAX 来删除这些字段。这实现了快速界面的外观 ->更好的用户体验。但是,如果 AJAX 调用在服务器端失败(无法删除字段),则先前删除的 HTML 字段将为用户提供错误的假设(它们被删除)。
选项2: 删除字段时,运行 AJAX,根据其成功情况,删除 HTML 或不删除。这为用户提供了准确的反馈,但表单会冻结,直到 AJAX 调用完成 = 慢(呃)。
你有什么想法?哪种方法对我来说似乎更好,或者我应该将其作为一种选择?
I'd like to ask your opinion on this. This is a theoretical question.
I'm in a situation where I have an interface shown to a user that uses AJAX to talk to the server. The server-side language does not matter here. I have a form with fields and each of them are deletable. If the user selects a few "delete" -checkboxes and presses Update, then I have these two options to do:
Option 1:
When deleting fields, use JavaScript to remove the HTML immediately and run AJAX on background to delete those fields. This achieves a look of a fast interface -> better user experience. However, if the AJAX call fails on the server side (the fields couldn't be deleted), then the previously deleted HTML fields would give a false assumption for the user (of them being deleted).
Option 2:
When deleting fields, run AJAX, depending on its success, either remove the HTML or do not. This gives accurate feedback for the user, but the form would freeze until the AJAX call finishes = slow(er).
What are your thoughts? Which approach seems better for me to take or should I make it an option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
选项3:将控件标记为已删除(例如,覆盖一个半透明的灰色框,上面有删除图标)。发送请求。当它返回时,删除控件,或更改框以显示错误图标几秒钟(然后删除框)。
在此过程中允许与界面的其余部分进行交互。
Option 3: Mark the controls as being deleted (e.g. overlay a translucent gray box with a delete icon on it). Send the request. When it returns, either remove the controls, or change the box to show an error icon for a few seconds (then remove the box).
Allow the rest of the interface to be interacted with while this goes on.
好问题。
第三种选择是:
这会向用户反馈某些内容已被有效请求(响应性),
同时还显示有效完成的时刻。
此外,用户以某种方式感觉到“远程呼叫”,这不会导致他错误,因为它确实发生了。无论如何,我们无法做任何有意义的事情来隐藏这种感觉,因为延迟永远存在。
Nice question.
A third option would be to :
This gives the user feedback that something was effectively requested (responsiveness),
while showing also the moment where it is effectively completed.
Also, the user somehow feels the "distant call", which does not induce him in error, because it is was really happens. Anyway, there is nothing meaningful we can do to hide this feeling, because the delay will always be there.