0

我在页面上有一个项目和任务列表。我希望简单地显示某人何时正在编辑任务记录。有没有一种相当简单的方法让 jquery 监听数据库更改并将行标记为“锁定”我并不是说它会禁用任何东西,只是向用户表明有人正在进行更改。

然后我可以让用户重新加载页面以在保存更改时显示更新的数据。

谢谢,巴特

4

1 回答 1

1

setInterval()应该做的伎俩。只需让您的 JS 每隔一段时间 ping 后端,即可查看数据库是否仍处于锁定状态。

此外,使用 jQuery 和 AJAX,如果页面解锁,您将不需要用户刷新页面。伪代码:

setInterval($.get(attrs to whatever back end script that will actually do the heavy lifting), 5000); // ping every five seconds

// in $.get, you can display different things based on whether or not the back end
// response says it's locked
于 2012-10-15T18:52:10.413 回答