AJAX 和动作预测

发布于 2024-08-09 11:26:38 字数 426 浏览 4 评论 0原文

我想问问你对此的看法。这是一个理论问题。

我遇到的情况是,我向用户显示一个使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青衫负雪 2024-08-16 11:26:38

选项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.

辞别 2024-08-16 11:26:38

好问题。

第三种选择是:

  1. 立即禁用控件
  2. 删除当 Ajax 返回时

这会向用户反馈某些内容已被有效请求(响应性),
同时还显示有效完成的时刻。


此外,用户以某种方式感觉到“远程呼叫”,这不会导致他错误,因为它确实发生了。无论如何,我们无法做任何有意义的事情来隐藏这种感觉,因为延迟永远存在。

Nice question.

A third option would be to :

  1. disable immediately the controls
  2. delete them when the Ajax returns

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文