前端部分:
$.ajax({
type: 'post',
url: 'ajax/flyso.aspx?action=do',
data: $(".flysoForm").serialize(),
success: function (data) {
if (data == 1) {
succ("留言成功!");
$(".lxform")[0].reset();
}
else if (data == 3)
warn("一小时内只允许提交3次!");
else
alert("留言失败!");
}
});
后端部分:
Hashtable ht = Requests.GetAllValues();
ht["ip"] = Client.IPAddress;
if (TSQL.LookUpInt("select count(1) from t_flyso where ip='" + ht["ip"] + "' and datediff(hour,addtime,getdate())=0") >= 3)
{
Response.Write("3");
return;
}
int i = TSQL.Insert("t_flyso", ht); //新增
if (i > 0)
{
Response.Write("1");
}
else
Response.Write("2");