jquery监听数据库的变化

时间:2012-10-15 18:44:46

标签: php jquery mysql

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

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

谢谢, 巴特

1 个答案:

答案 0 :(得分:1)

setInterval()应该做到这一点。只需让你的JS经常检查后端,看看db是否仍然被锁定。

此外,使用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
相关问题