function commentpost(){
var allow = true;
var game = "<?php echo $game ?>";
var name = $("input#name").val();
var comment = $("textarea#comment").val();
var date = currentdate();
var dataString = "postdate=" + date + "&game=" + game + "&name=" + name + "&comment=" + comment;
if(name && comment && allow){
$.ajax({
type: "POST",
url: "../php/addcomment.php",
data: dataString,
success: function(){
updatecomments();
//important part here V
allow = false;
setTimeout(function(){
allow = true;
// alert(allow);
}, 5000);
// alert(allow);
//important part here ^
}
});
}
//important part here V
else if ((!name || !comment) && allow){
alert("Please fill out both the Name and Comment fields");
}
else if (!allow){
alert("Commenting has been limited to 5 seconds in between to pevent spamming.");
}
//important part here ^
}
作成中の Web サイトに、小さくて基本的なコメント スクリプトがあります。それはすべて正常に機能しますが、送信ボタンがスパムにならないようにしています。これは私には機能するはずですが、何らかの理由で機能しないようです。「許可」の使い方が原因だと思います。