中国1 0乌兹别克斯坦:ajax 相同URL每2分钟才能发1次请求吗????

来源:百度文库 编辑:高考问答 时间:2024/04/25 09:14:45
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
var req;
function executeXhr(url) {
req = false;
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processAjaxResponse;
req.open("GET", url, true);
req.send("");
}
else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processAjaxResponse;
req.open("GET", url, true);
req.send("");
}
}
}
function processAjaxResponse() {
if (req.readyState == 4) {
if (req.status == 200) {
document.getElementById("returnStr").innerHTML = req.responseText;
req = null;
} else {
alert("There was a problem retrieving the XML data:"+req.statusText);
}
}
}
function doSubmit() {
//alert("The URL:"+'http://127.0.0.1:8080/tomcat_study/study?txt='+form1.textfield.value);
executeXhr('http://127.0.0.1:8080/tomcat_study/study?txt='+form1.textfield.value)
}
</script>
</head>

<body>
<form name="form1" method="post" action="">
<input type="button" name="Submit" value="按钮" onClick="doSubmit();">
<input type="text" name="textfield">
</form>
<div id="returnStr">
result:
</div>
</body>
</html>

URL不变的话,我一直按Button,服务端只收到第一条请求,其他的收不到,URL不变,过2-3分钟,再发,服务端又可以收到请求。
但只要一修改URL,提交,服务端又会马上收到请求。
请问这是怎么会使?