为什么我写的javascript:刷新页面,数据既然没有更新也就是说,数据库里的数据是新的而页面上是通过javascript:无刷新请求,但是数据还没有更新,什么原因,请大家帮帮忙,这里有几个javascript脚本,是实现10秒刷新一次。var count=0;
//刷新本页面
function onLoadInte(){
document.getElementById("timeDiv").innerText=count;//显示刷新时间
if(count>=10){
count=0;
reFlushPage("station.do?operate=minStations&pagenum=<%=pageNum%>&pagesize=<%=pageSize%>");
}
count=count+1;
ti=window.setTimeout("onLoadInte()", 1000);
}
//创建XMLHttpReq
var XMLHttpReq = false;
function createXMLHttpRequest(){
if(window.XMLHttpRequest){
XMLHttpReq = new XMLHttpRequest();
}else if(window.ActiveXObject){
try{
XMLHttpReq = new ActiveXObject("MSXML2.XMLHTTP");
}catch(e){
try{
XMLHttpReq = new ActiveXObject("Mircsoft.XMLHTTP");
}catch(e1){}
}
}
}
//定义页面无刷新功能
function reFlushPage(url){
createXMLHttpRequest();
XMLHttpReq.open("GET","admin/dataManager/stationsmin.jsp",true);
XMLHttpReq.onreadystatechange = processResponse;
XMLHttpReq.send(null);
}
function processResponse(){
if(XMLHttpReq.readyState == 4){
if(XMLHttpReq.status == 200){
// var res = XMLHttpReq.responseXML.getElementsByTagName("res")[0].firstChild.data;
// window.alert(res);
}else{
window.alert("你请求的页面有异常");
}
}
}
//刷新本页面
function onLoadInte(){
document.getElementById("timeDiv").innerText=count;//显示刷新时间
if(count>=10){
count=0;
reFlushPage("station.do?operate=minStations&pagenum=<%=pageNum%>&pagesize=<%=pageSize%>");
}
count=count+1;
ti=window.setTimeout("onLoadInte()", 1000);
}
//创建XMLHttpReq
var XMLHttpReq = false;
function createXMLHttpRequest(){
if(window.XMLHttpRequest){
XMLHttpReq = new XMLHttpRequest();
}else if(window.ActiveXObject){
try{
XMLHttpReq = new ActiveXObject("MSXML2.XMLHTTP");
}catch(e){
try{
XMLHttpReq = new ActiveXObject("Mircsoft.XMLHTTP");
}catch(e1){}
}
}
}
//定义页面无刷新功能
function reFlushPage(url){
createXMLHttpRequest();
XMLHttpReq.open("GET","admin/dataManager/stationsmin.jsp",true);
XMLHttpReq.onreadystatechange = processResponse;
XMLHttpReq.send(null);
}
function processResponse(){
if(XMLHttpReq.readyState == 4){
if(XMLHttpReq.status == 200){
// var res = XMLHttpReq.responseXML.getElementsByTagName("res")[0].firstChild.data;
// window.alert(res);
}else{
window.alert("你请求的页面有异常");
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货