87,993
社区成员
发帖
与我相关
我的任务
分享
请各位大神帮忙看看这个问题???
[/quote]
[/quote]


// 上次评论时间
var lastCommentDate; // 这个值可以从后台传到页面
function submitComment(){
// 提交时检查上次评论时间
if(lastCommentDate && (new Date() - lastCommentDate) > 30 * 60 * 1000)
return alert('too often');
// 也可以在发送请求之前就记上次评论时间, 而非等待成功评论返回
// lastCommentDate = new Date();
// jquery的ajax为例
$.ajax({
url: 'xxxxx',
success: function(data){
// 在评论成功后设置时间
lastCommentDate = new Date();
}
});
}