相思资源网 Design By www.200059.com
复制代码 代码如下:
function initXMLRequest(){
if (window.ActiveXObject) {
xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
} else {
if (window.XMLHttpRequest) {
xmlRequest = new XMLHttpRequest();
}
}
}
function sendHTTPRequest(){
initXMLRequest();
var url = "monitor!taskdata.action"; //调用的servlet
if (xmlRequest) {
xmlRequest.open("POST", url, true);
xmlRequest.send(null);
xmlRequest.onreadystatechange = isDataExists;
//使用方法回调,每5秒调用一次
setTimeout("sendHTTPRequest()",5000);
}
}
function isDataExists(){
if (xmlRequest.readyState == 4) {
if (xmlRequest.status == 200) {
var data = eval("("+xmlRequest.responseText+")");
// 获取tbody的表格内容
var taskTable = document.getElementById("tasktbody");
for(var i=taskTable.childNodes.length-1;i>=0;i--){
taskTable.removeChild(taskTable.childNodes[i]);
}
$.each(data, function(i,val){
var newTR = taskTable.insertRow(taskTable.rows.length);
newTR.id="taskdata_"+(i+1);
newTR.ondblclick=getdetail;
newTR.onclick=selectRow;
backColor(val.taskstatus,newTR);
var newNameTD=newTR.insertCell(0);
newNameTD.innerHTML = val.taskname;
newNameTD.id="taskname_"+(i+1);
var newStatusTD=newTR.insertCell(1);
newStatusTD.innerHTML = val.taskstatus;
newStatusTD.id="taskstatus_"+(i+1);
var newArgTD=newTR.insertCell(2);
newArgTD.innerHTML = val.data_start_time;
var newOtherArgTD=newTR.insertCell(3);
newOtherArgTD.innerHTML = val.schedule_interval;
var newdateformatTD=newTR.insertCell(4);
newdateformatTD.innerHTML = val.next_execution_time;
var newbackwordTD=newTR.insertCell(5);
newbackwordTD.innerHTML = val.taskdetailscount;
var newpriorityTD=newTR.insertCell(6);
newpriorityTD.innerHTML = val.statusruncount;
var newleftTD=newTR.insertCell(7);
newleftTD.innerHTML = val.statusfinishcount;
var newlefttimeTD=newTR.insertCell(8);
newlefttimeTD.innerHTML = val.statuserrorcount;
});
}
}
}
function initXMLRequest(){
if (window.ActiveXObject) {
xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
} else {
if (window.XMLHttpRequest) {
xmlRequest = new XMLHttpRequest();
}
}
}
function sendHTTPRequest(){
initXMLRequest();
var url = "monitor!taskdata.action"; //调用的servlet
if (xmlRequest) {
xmlRequest.open("POST", url, true);
xmlRequest.send(null);
xmlRequest.onreadystatechange = isDataExists;
//使用方法回调,每5秒调用一次
setTimeout("sendHTTPRequest()",5000);
}
}
function isDataExists(){
if (xmlRequest.readyState == 4) {
if (xmlRequest.status == 200) {
var data = eval("("+xmlRequest.responseText+")");
// 获取tbody的表格内容
var taskTable = document.getElementById("tasktbody");
for(var i=taskTable.childNodes.length-1;i>=0;i--){
taskTable.removeChild(taskTable.childNodes[i]);
}
$.each(data, function(i,val){
var newTR = taskTable.insertRow(taskTable.rows.length);
newTR.id="taskdata_"+(i+1);
newTR.ondblclick=getdetail;
newTR.onclick=selectRow;
backColor(val.taskstatus,newTR);
var newNameTD=newTR.insertCell(0);
newNameTD.innerHTML = val.taskname;
newNameTD.id="taskname_"+(i+1);
var newStatusTD=newTR.insertCell(1);
newStatusTD.innerHTML = val.taskstatus;
newStatusTD.id="taskstatus_"+(i+1);
var newArgTD=newTR.insertCell(2);
newArgTD.innerHTML = val.data_start_time;
var newOtherArgTD=newTR.insertCell(3);
newOtherArgTD.innerHTML = val.schedule_interval;
var newdateformatTD=newTR.insertCell(4);
newdateformatTD.innerHTML = val.next_execution_time;
var newbackwordTD=newTR.insertCell(5);
newbackwordTD.innerHTML = val.taskdetailscount;
var newpriorityTD=newTR.insertCell(6);
newpriorityTD.innerHTML = val.statusruncount;
var newleftTD=newTR.insertCell(7);
newleftTD.innerHTML = val.statusfinishcount;
var newlefttimeTD=newTR.insertCell(8);
newlefttimeTD.innerHTML = val.statuserrorcount;
});
}
}
}
标签:
ajax,定时调用
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无ajax的定时调用每5秒调用一次的评论...