日期:2014-05-20 浏览次数:20718 次
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'refresh.jsp' starting page</title> <script type='text/javascript' src='/refresh_cdd/dwr/interface/CDD.js'></script> <script type='text/javascript' src='/refresh_cdd/dwr/engine.js'></script> <script type='text/javascript' src='/refresh_cdd/dwr/util.js'></script> <script type="text/javascript" src="js/prototype.js"></script> <script type="text/javascript"> var timeOK; function startRefresh(){ CDD.loadAll(filltable); timeOK = window.setTimeout("startRefresh();",2000); } function stopRefresh(){ window.clearTimeout(timeOK); } function filltable(xhr){ resetTable(); var c = $("showdata"); xhr.each(function(use){ c.appendChild(createTR(use)); }); } function createTR(data){ var createTR = document.createElement("TR"); var createTD_ID = document.createElement("TD"); var createTD_NAME = document.createElement("TD"); var createTD_PRICE = document.createElement("TD"); var createTD_SHULIANG = document.createElement("TD"); createTD_ID.innerHTML = data.id; createTD_NAME.innerHTML = data.name; createTD_PRICE.innerHTML = data.price; createTD_SHULIANG.innerHTML = data.shuliang; createTR.appendChild(createTD_ID); createTR.appendChild(createTD_NAME); createTR.appendChild(createTD_PRICE); createTR.appendChild(createTD_SHULIANG); return createTR; } function resetTable(){ var tbd = $("showdata"); var size = tbd.childNodes.length; for(var i=0;i<size;i++){ tbd.removeChild(tbd.lastChild); } } function init(){ CDD.Thread_cdd(); } </script> </head> <body onload="init();"> <table> <tbody id="showdata"> <tr> <th>员工编号</th> <th>员工名字</th> <th>价格</th> <th>数量</th> </tr> </tbody> </table> <form> <input type="button" value="开始2秒中刷新" onclick="startRefresh();"/> <input type="button" value="停止刷新" onclick="stopRefresh();"/> </form> </body> </html>