数据应该在什么时候发送回服务器?
stackexchange 的“rate”按钮就是一个很好的例子。当帖子被点赞时,箭头会立即改变颜色。然而,人们有一段宽限期来编辑自己的投票决定(哎呀!错误投票?)。投票操作是立即处理还是仅在设定的时间段后或用户离开页面时处理?这个评级究竟是如何处理的?
处理动态页面编辑的标准是什么(例如 stackexchange 评级、facebook 帖子?)
A good example would be the stackexchange "rate" button. When a post is upvoted the arrow changes color immediately. However there is a grace period for one to edit one's vote decision (oops! voted by mistake?). Is the upvote action processed immediately or does is only process after a set time period, or when the user leaves the page? How exactly is this rating processed?
What is the standard for handling dynamic page edits (e.g. stackexchange rating, facebook posts?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,我建议您立即进行更改。如果有一个“宽限期”,那么在服务器端实现(如果可以改善用户体验,您也可以在客户端实现)。
因此,如果有人对某个帖子进行了投票,该帖子会立即通过 ajas 保存,但如果他们在宽限期内改变了主意,服务器就会撤消投票。一旦“宽限期”结束,服务器就会拒绝更改。
当您点击“发布”等时,Facebook 帖子(显然)会被保存——但在此之前它不会被保存。
像 Blogger 或 Google Docs 这样的东西完全是另一个问题——它每隔 x 秒自动保存一次。这完全取决于开发商。通常,您希望在不影响性能或降低用户体验的情况下尽可能频繁地进行此操作。
Generally I would recommend that you make the changes immediately. If there's to be a "grace period", then implement that on the server side (you can do it client side too if it will improve user experience).
So if someone upvotes a post, it is saved immediately via ajas, but then if they change their minds within the grace period, the server undoes the vote. Once the "grace period" is up, the server rejects the change.
A Facebook post would (obviously) be saved when you click "Post", etc. -- but it wouldn't be saved before then.
Something like Blogger or Google Docs is another issue altogether -- where it's automatic saving every x number of seconds. That is purely up to the developer. Generally you want to make it as often as possible without impacting performance or decreasing the user experience.