How to set the time to send only one request

  • 2020-03-30 02:11:55
  • OfStack

 
<%@ 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 one request can be sent at a given 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 once a minute! "); 
} 
} 
function CountDown(){ 
if(maxtime>=0){ 
seconds = Math.floor(maxtime%60); 
msg = " There's still time to go "+seconds+" seconds "; 
$("#btn").val(msg); 
--maxtime; 
}else{ 
$("#btn").val(" submit "); 
clearInterval(btn); 
maxtime = 10; 
} 
} 
function check(){ 
alert(" Haha, it's my turn! "); 
} 

</SCRIPT> 
</head> 
<body> 
<input type="button" id="btn" value=" submit " onclick="test(this)"/> 
</body> 
</html> 

Related articles: