The code copy is as follows:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Only once a request can be sent within a certain period of time</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/editor/jquery/jquery-1.4.4.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<SCRIPT LANGUAGE="JavaScript">
var maxtime = 10;//Set at least 10 to send a request
function test(obj){
if(obj.value=='Submit'){
check();
btn = setInterval("CountDown()",1000);
}else{
alert("Only send once in a minute!");
}
}
function CountDown(){
if(maxtime>=0){
seconds = Math.floor(maxtime%60);
msg = "There are still "+seconds+" seconds" when the time ends;
$("#btn").val(msg);
--maxtime;
}else{
$("#btn").val("Commit");
clearInterval(btn);
maxtime = 10;
}
}
function check(){
alert("Haha, it's me!");
}
</SCRIPT>
</head>
<body>
<input type="button" id="btn" value="submit" onclick="test(this)"/>
</body>
</html>