【jQuery】: 定时刷新页面
<%@page import="qflag.ucstar.seatmonitor.manager.SeatMonitorManager"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<html>
<head>
<link href="js/css/footable-0.1.css" rel="stylesheet" type="text/css" />
<link href="js/css/footable.sortable-0.1.css" rel="stylesheet"
type="text/css" />
<link href="js/css/footable.paginate.css" rel="stylesheet"
type="text/css" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/footable.js" type="text/javascript"></script>
<script src="js/footable.sortable.js" type="text/javascript"></script>
<script src="js/footable.paginate.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() { //ajax定时刷新table
run(); //加载页面时启动定时器
chat();
function chat() { // var dateObj = new Date();
$
.post(
'seatMonitorData.jsp?action=getData',
{},
function(data) {
//alert('1');
var jsonStr = eval("(" + data + ")");
if (jsonStr != undefined && jsonStr.length > 0) {
for ( var i = 0; i < jsonStr.length; i++) { //双次迭代出数组 以及数组里面的json数组
var t5 = jsonStr[i].curstatus;
var jsontr = jsonStr[i].seatid;
var jsontr1 = jsonStr[i].children;
var time4 = jsonStr[i].statustime;
if(!time4.length > 0 ){
var time4 = '0';
}
if (jsontr1 != undefined
&& jsontr1.length > 0) {
for ( var y = 0; y < jsontr1.length; y++) {
var time1 = jsontr1[y].chattime;
var time2 = jsontr1[y].rspstime;
var time3 = jsontr1[y].waittime;
}
} else {
var time1 = '0';
var time2 = '0';
var time3 = '0';
}
var time = parseFloat(time1) / 1000; //日期转换 //毫秒转换为 时/分/秒
if (null != time && "" != time) {
if (time > 60 && time < 60 * 60) {
time = parseInt(time / 60.0)
+ "分钟"
+ parseInt((parseFloat(time / 60.0) - parseInt(time / 60.0)) * 60)
+ "秒";
} else if (time >= 60 * 60
&& time < 60 * 60 * 24) {
time = parseInt(time / 3600.0)
+ "小时"
+ parseInt((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60)
+ "分钟"
+ parseInt((parseFloat((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60) - parseInt((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60)) * 60)
+ "秒";
} else {
time = parseInt(time) + "秒";
}
} else {
time = "0 时 0 分0 秒";
}
var time2s = parseFloat(time2) / 1000; //日期转换
if (null != time2s && "" != time2s) {
if (time2s > 60 && time2s < 60 * 60) {
time2s = parseInt(time2s / 60.0)
+ "分钟"
+ parseInt((parseFloat(time2s / 60.0) - parseInt(time2s / 60.0)) * 60)
+ "秒";
} else if (time2s >= 60 * 60
&& time2s < 60 * 60 * 24) {
time2s = parseInt(time2s / 3600.0)
+ "小时"
+ parseInt((parseFloat(time2s / 3600.0) - parseInt(time2s / 3600.0)) * 60)
+ "分钟"
+ parseInt((parseFloat((parseFloat(time2s / 3600.0) - parseInt(time2s / 3600.0)) * 60) - parseInt((parseFloat(time2s / 3600.0) - parseInt(time2s / 3600.0)) * 60)) * 60)
+ "秒";
} else {
time2s = parseInt(time2s) + "秒";
}
} else {
time2s = "0 时 0 分0 秒";
}
var time3s = parseFloat(time3) / 1000; //日期转换
if (null != time3s && "" != time3s) {
if (time3s > 60 && time3s < 60 * 60) {
time3s = parseInt(time3s / 60.0)
+ "分钟"
+ parseInt((parseFloat(time3s / 60.0) - parseInt(time3s / 60.0)) * 60)
+ "秒";
} else if (time3s >= 60 * 60
&& time3s < 60 * 60 * 24) {
time3s = parseInt(time3s / 3600.0)
+ "小时"
+ parseInt((parseFloat(time3s / 3600.0) - parseInt(time3s / 3600.0)) * 60)
+ "分钟"
+ parseInt((parseFloat((parseFloat(time3s / 3600.0) - parseInt(time3s / 3600.0)) * 60) - parseInt((parseFloat(time3s / 3600.0) - parseInt(time3s / 3600.0)) * 60)) * 60)
+ "秒";
} else {
time3s = parseInt(time3s) + "秒";
}
} else {
time3s = "0 时 0 分0 秒";
}
var time4s = parseFloat(time4) / 1000; //日期转换
if (null != time4s && "" != time4s) {
if (time4s > 60 && time4s < 60 * 60) {
time4s = parseInt(time4s / 60.0)
+ "分钟"
+ parseInt((parseFloat(time4s / 60.0) - parseInt(time4s / 60.0)) * 60)
+ "秒";
} else if (time4s >= 60 * 60
&& time4s < 60 * 60 * 24) {
time4s = parseInt(time4s / 3600.0)
+ "小时"
+ parseInt((parseFloat(time4s / 3600.0) - parseInt(time4s / 3600.0)) * 60)
+ "分钟"
+ parseInt((parseFloat((parseFloat(time4s / 3600.0) - parseInt(time4s / 3600.0)) * 60) - parseInt((parseFloat(time4s / 3600.0) - parseInt(time4s / 3600.0)) * 60)) * 60)
+ "秒";
} else {
time4s = parseInt(time4s) + "秒";
}
} else {
time4s = "0 时 0 分0 秒";
}
if (t5 != null && t5 != '') {
if (t5 == "online") {
v5 = '<font size="+1" ace="黑体" color="#FF00FF"> 就绪</font>';
} else if (t5 == "busy") {
v5 = ' 未就绪';
} else if (t5 == "away") {
v5 = ' 休息';
}
}
if (!$("#" + jsontr).length > 0) {
var tr = '<tr id='+jsontr+'><td>'
+ jsonStr[i].seatid
+ '</td>';
tr += '<td> ' + time + '</td>';
tr += '<td> ' + time2s + '</td>';
tr += '<td> ' + time3s + '</td>';
tr += '<td>' + v5 + '</td>';
tr += '<td> ' + time4s + '</td>';
tr += '<td>'
+ jsonStr[i].curservice
+ '</td>';
tr += '<td>'
+ jsonStr[i].servicecount
+ '</td>';
tr += '</tr>';
$("#time5").append(tr);
} else {
$("#time5").empty();
var tr = '<tr id='+jsontr+'><td>'
+ jsonStr[i].seatid
+ '</td>';
tr += '<td> ' + time + '</td>';
tr += '<td> ' + time2s + '</td>';
tr += '<td> ' + time3s + '</td>';
tr += '<td>' + v5 + '</td>';
tr += '<td> ' + time4s + '</td>';
tr += '<td>'
+ jsonStr[i].curservice
+ '</td>';
tr += '<td>'
+ jsonStr[i].servicecount
+ '</td>';
tr += '</tr>';
$("#time5").append(tr);
}
}
} else { //退出则清空缓存数据
$("#time5").empty();
}
});
}
var interval;
function run() {
interval = setInterval(chat, "5000");
}
});
</script>
</head>
<body leftmargin=0 topmargin=0 marginheight=0 weightmargin=0>
<div id="time">
<table class="footable" align="center" >
<thead style="background:#D5E1F2">
<tr>
<th>坐席工号</th>
<th>会话时长</th>
<th>响应时长</th>
<th>等待回复时长</th>
<th>当前状态</th>
<th>持续时长</th>
<th>当前服务数量</th>
<th>总服务数</th>
</tr>
</thead>
<tbody id="time5" align="center"></tbody>
</table>
</div>
</body>
</html>
【jQuery】: 定时刷新页面的更多相关文章
- php+ajax+jquery 定时刷新页面数据
testajax.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: ...
- JS定时刷新页面及跳转页面
JS定时刷新页面及跳转页面 Javascript 返回上一页1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2); 2. history ...
- JSP简单练习-定时刷新页面
<%@ page contentType="text/html; charset=gb2312" %> <%@ page import="java.ut ...
- Angular 定时器$timeout和$interval关于定时刷新页面和发送请求的用法
项目中有用到定时器定时刷新页面的数据,在网上查看了一些资料,整理了一下,备忘. $timeout 用法如下:$timeout(fn,[delay],[invokeApply]); fn:一个将被延迟执 ...
- 定时刷新页面SetInterval 和setTimeout -时间间隔可以动态设定
JS里设定延时: 使用SetInterval和设定延时函数setTimeout 很类似.setTimeout 运用在延迟一段时间,再进行某项操作. setTimeout("function& ...
- js定时刷新页面.
//页面定时刷新.2017.09.27 $(document).ready(function () { self.setInterval(function () { var d = new Date( ...
- http-equiv="Refresh" 实现定时刷新页面
***.html自动跳转文件代码如下: <HTML> <HEAD><META http-equiv="Refresh" content="5 ...
- Vue使用定时器定时刷新页面
1. 需求说明 在前端开发中,往往会遇到页面需要实时刷新数据的情况,给用户最新的数据展示. 2. 逻辑分析 如果需要数据实时更新,我们自然是需要使用定时器,不断的调用接口数据,会相对的消耗内存. 3. ...
- Ajax实现定时刷新页面
function deleteValue(){ var refresh = function() { $.ajax({ type:'post', url:'/Application/index ...
随机推荐
- V$RMAN_BACKUP_JOB_DETAILS
V$RMAN_BACKUP_JOB_DETAILS展示了rman备份的相关细节.比如,rman备份持续时间.rman备份的执行次数.每一次rman备份工作的状态(failed or completed ...
- java日期比较,日期计算
版权声明:本文为楼主原创文章,未经楼主允许不得转载,如要转载请注明来源. 都是常用的日期之间的比较方法,供以后参考. 热身:获取当前时间 SimpleDateFormat df = new Simpl ...
- 通过案例对 spark streaming 透彻理解三板斧之二:spark streaming运行机制
本期内容: 1. Spark Streaming架构 2. Spark Streaming运行机制 Spark大数据分析框架的核心部件: spark Core.spark Streaming流计算. ...
- C# 控制台程序如何能不显示窗口
创建好控制台程序后,选中项目,右键,属性,输出类型选为“windows 应用程序” 这样就没有dos窗口了
- 26、首先通过javascript包的异步加载来学习echarts包的结构
1.在这里先写一写前言,今天在公司搞定了一个对于滚动条进行定位的case,明天开始做TestManagement. 首先大家先来一起看一看流行的javascript文件的加载方式,这里采用别人博客上的 ...
- knockoutJS+knockout.multimodels使用记录
可以多次绑定,但不能嵌套绑定 错误示例: <div class="con_c" data-model="viewModel"> <div da ...
- Oracle中 Package与Package body的介绍
1.Oracle Package的作用: 可以简化应用设计.提高应用性能.实现信息隐藏.子程序重载 2.ORACLE中的function .package.package bodies.pro ...
- asp.net项目下的web service返回json数据问题
App_Code目录下放置WebService.cs文件,文件内容如: using System; using System.Collections.Generic; using System.Dat ...
- linux C学习笔记02--共享内存(进程同步)
system V下3中进程同步:共享内存(shared memory),信号量(semaphore)和消息队列(message queue) 调试了下午,终于调通啦! 运行./c.out 输出共享内存 ...
- 十步图解CSS的position
CSS的positon,我想做为一个Web制作者来说都有碰到过,但至于对其是否真正的了解呢?那我就不也说了,至少我自己并不非常的了解其内核的运行.今天在Learn CSS Positioning in ...