【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 ...
随机推荐
- LayoutInflater.java (android-19)
/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Versi ...
- Java为什么会引入及如何使用Unsafe
综述 sun.misc.Unsafe至少从2004年Java1.4开始就存在于Java中了.在Java9中,为了提高JVM的可维护性,Unsafe和许多其他的东西一起都被作为内部使用类隐藏起来了.但是 ...
- C# Dictionary 的几种遍历方法
Dictionary<string, int> list = new Dictionary<string, int>(); list.Add("d", 1) ...
- ORA-15028: ASM file '..' not dropped; currently being accessed --转载
Couple of weeks ago we had a problem with one of our busiest databases. The FRA was filling quite ra ...
- Linux下的GNU Emacs 24命令_信息竞赛使用_C++
C代表Ctrl,M代表Alt 一.文件命令 C-x b 新建 build C-x C-f 打开文件 find C-s 保存文件 save C-x C-w 另存为 为wei w C-x C-b 打开所有 ...
- 一个CString的实现 拷贝构造函数的应用
class CString { public: CString (char* s); CString(); ~CString(); private: char *str; int len; stati ...
- Android BaseAdapter的使用
数据适配器有很多种,今天在这里记录一下最通用是适配器BaseAdapter. 首先说一下什么是适配器,这里我从网上找到一幅图片 由上图我们不难看出,所谓的适配器,就是数据与视图之间的桥梁.由它把数据绑 ...
- 图片form表单提交和id提交
<form action="${pageContext.request.contextPath }/sarchServlet" method="post" ...
- eclipes(小白)快捷键
Ctrl+shift+l :自动列出全部快捷键 alt+/ :内容助理 Ctrl+1. :快速修复 Ctrl+shift+o ...
- Study Emgu VoteForUniqueness
Recently i was studying Emgu, but find there is a bug in the VoteForUniqueness function in class Fea ...