【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 ...
随机推荐
- Angular(1)
1.设计原则 1.YAGNI 不要把未来需求引入当前工程 2.KISS keep it simple and stupid 语义化标记 合理注释 符合规定的命名 3.DRY(don't re ...
- php读取出字符串中的img标签中的图片路径
php读取出字符串中的img标签中的图片路径 $pageContents = '字符串,带img标签'; $pageContents = str_replace('\"','"', ...
- Java多线程-线程的同步与锁
一.同步问题提出 线程的同步是为了防止多个线程访问一个数据对象时,对数据造成的破坏.例如:两个线程ThreadA.ThreadB都操作同一个对象Foo对象,并修改Foo对象上的数据. package ...
- jQuery - 疑惑
设置内容和属性:http://www.runoob.com/jquery/jquery-dom-set.html
- “请运行Chkdsk工具”怎么解决
今天重新系统,想从移动硬盘中拷贝数据,但是老是提示:“请运行Chkdsk工具” 于是在百度搜索一下,有人提供的解决方案很不错,在些引用一下,以备忘! 电脑上经常遇到这样的提示“某某某文件已损坏且无法读 ...
- AS3下如何来判断XML属性的是否存在
在as3中判断xml节点是否存在可用XMLList中的方法:hasOwnProperty(p:String):Boolean. 但是判断xml节点是否存在某一属性,对象中好像没有该方法,只能用unde ...
- 解决sqoop需要输入密码的问题
修改配置文件:vi /etc/sqoop/conf/sqoop-site.xml <property> <name>sqoop.metastore.client.record. ...
- javascript解析引擎(每天有学习一点篇)
======================================================= 有一段时间,经常耳闻web前端的福音,对高性能的V8议论纷纷. 其实对js解析引擎没有深 ...
- Ms sql将首字母大写
--辅助表 create table a ( a int ) declare @b int begin insert into a values(@b) end; go --表数据 ),id int) ...
- 在启动dubbo框架时报错。Unable to connect to zookeeper server within timeout: 5000
这是因为zookeeper服务没有启动,所以会报错超时.只要启动zookeeper就行了. zookerper的启动很简单的,网上随便搜搜都有.