Copy codeThe Code is as follows:
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 "; // call the servlet
If (xmlRequest ){
XmlRequest. open ("POST", url, true );
XmlRequest. send (null );
XmlRequest. onreadystatechange = isDataExists;
// Method callback, called every 5 seconds
SetTimeout ("sendHTTPRequest ()", 5000 );
}
}
Function isDataExists (){
If (xmlRequest. readyState = 4 ){
If (xmlRequest. status = 200 ){
Var data = eval ("(" + xmlRequest. responseText + ")");
// Obtain the tbody table content
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;
});
}
}
}