我使用jQuery将数据从表单提交到我的控制器文件。
它在数据库中添加了自己喜欢的内容,但是,如何防止用户过于频繁地发送数据到ajax脚本呢?
我的意思是,我可以在我的表单中点击提交按钮上千次-如何防止这种情况?那么它将是例如,每10秒1个请求?
发布于 2012-04-14 23:59:37
就在我的头上,我会说这样的话:
$("#button_id").one('click', DoSomething); // attaches the function for ONE click
function DoSomething() {
$.post("test.php", function(data) {
alert("Data Loaded: " + data);
$("#button_id").delay(10000).one('click', DoSomething); // reattach the listener
});
}
从this question和jQuery manual复制的源
https://stackoverflow.com/questions/10154691
复制相似问题