页面加载后执行ajax请求,去后台取数据,然后更新页面内的table,现在ajax请求是每隔一秒请求一次,现在页面内的其他按钮都不能点击了,请问有什么办法能解决这个问题吗代码大致像下面这样:
function readlog(){
...
ajax.requet(url,callback);
...
}
callback = function(data){
addrow(data);
setTimeout(readlog,1000);
}
function addrow(data){
...
}
function readlog(){
...
ajax.requet(url,callback);
...
}
callback = function(data){
addrow(data);
setTimeout(readlog,1000);
}
function addrow(data){
...
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/../modules/base.jsp"%>
<%@ taglib uri="/WEB-INF/tlds/sitemesh-decorator.tld" prefix="decorator"%>
<%@ taglib uri="/WEB-INF/tlds/sitemesh-page.tld" prefix="page"%><%@page import="java.util.*"%>
<%@page import="java.util.ArrayList"%>
<%@ page import="com.mocha.netfocus.monitor.MonitorController"%>
<%@ page import="com.mdcl.mocha.netfocus.commons.I18NMessage"%>
<%@ page import="com.mocha.netfocus.util.constants.INetworkElementType"%>
<%
String uid = (String)request.getParameter("uid");
String monitorType = (String)request.getParameter("monitorType");
String nodeType = (String)request.getParameter("nodeType");
if(nodeType==null || "".equals(nodeType)){
nodeType = "";
} String reportStr = I18NMessage.getInstance().getMessage("netfocus.monitor.report");
String preStr = I18NMessage.getInstance().getMessage("netfocus.monitor.prepare");
String addedStr = I18NMessage.getInstance().getMessage("netfocus.monitor.success");
String failStr = I18NMessage.getInstance().getMessage("netfocus.monitor.failed");
String processStr = I18NMessage.getInstance().getMessage("netfocus.monitor.monitored");
String anotherUsedStr = I18NMessage.getInstance().getMessage("netfocus.monitor.anotherused");
String logStr = I18NMessage.getInstance().getMessage("netfocus.monitor.log");
String title="";
String infomsg = "";
title="批量加入监控";
//title = I18NMessage.getInstance().getMessage("");
infomsg = "将已选择的设备批量加入监控。";
//infomsg = I18NMessage.getInstance().getMessage(""); String typeHost = INetworkElementType.TOPO_TYPE_HOST;
String typeServer = INetworkElementType.TOPO_TYPE_SERVER;
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="decorator" content="blank" />
<title><%=title%></title>
<link type="text/css" href="<%=cssPath%>/ext-all.css" rel="stylesheet" />
<script type="text/javascript" src="<%=jsPath%>/ext-base.js" ></script>
<script type="text/javascript" src="<%=jsPath%>/ext-all.js" ></script>
<script type="text/javascript" src="<%=jsPath%>/ext-lang-zh_CN.js" ></script>
<script type="text/javascript" src="<%=jsPath%>/netfocus-components.js" ></script>
<script type="text/javascript" src="<%=jsPath%>/common.js" ></script>
<script type="text/javascript">
function background(){
var btnTxt = Ext.fly('backrun').dom.innerHTML;
if(btnTxt.indexOf("关闭")!=-1){
window.close();
}else{
window.blur();
}
}var stopflag = true;
function stop(){
if(stopflag){
document.frames["logsframe"].f_stop();
stopflag = false;
}else{
Mocha.smallAlert("监控已经停止");
}
}Ext.onReady(function() {
starttimes('clocktime','');
var s = '<iframe name="submitframe" height="0" width="0" src="javascript:document.open();document.write(\'<form name=createForm method=post></form>\');document.close();"></iframe>';
document.getElementById("d").innerHTML = s;
});//拓扑报告
function toporeport(){
var url = "<%=request.getContextPath()%>/netfocus.do?action=nodeoverviewservice@exportmonitorreport&uid=<%=uid%>&monitorType=<%=monitorType%>"+"&nodeType=<%=nodeType%>&isContainsAllNode=true";
var createForm = submitframe.document.forms["createForm"];
createForm.action = url;
createForm.submit();
}//修改运行时间
function modifyRuntime(){
var timeArr = document.frames["logsframe"].timeArr;
if(!timeArr || timeArr.length < 2){
return;
}
var arr1 = timeArr[0].split(":");
var arr2 = timeArr[timeArr.length-1].split(":");
var second = parseFloat(arr2[2]) - parseFloat(arr1[2]);
var minute = 0;
var hour = 0;
if (second < 0) {
second = 60 + second;
minute = parseFloat(arr2[1]) - parseFloat(arr1[1]) - 1;
if (minute < 0) {
minute = 60 + minute;
hour = parseFloat(arr2[0]) - parseFloat(arr1[0]) - 1;
} else {
hour = parseFloat(arr2[0]) - parseFloat(arr1[0]);
}
} else {
minute = parseFloat(arr2[1]) - parseFloat(arr1[1]);
if (minute < 0) {
minute = 60 + minute;
hour = parseFloat(arr2[0]) - parseFloat(arr1[0]) - 1;
} else {
hour = parseFloat(arr2[0]) - parseFloat(arr1[0]);
}
}
var result = (hour<10?"0"+hour:""+hour) + ":" + (minute<10?"0"+minute:""+minute) + ":" + (second<10?"0"+second:""+second);
document.getElementById('clocktime').innerHTML=result;
}
</script>
</head>
<body>
<page:applyDecorator name="panel">
<page:param name="action"></page:param>
<page:param name="formname">createForm</page:param>
<page:param name="title"><%=title%></page:param>
<page:param name="stop">stop();</page:param>
<page:param name="monitorreport">toporeport();</page:param>
<page:param name="background">background();</page:param>
<h2><div class="ico ico-clue"></div><%=infomsg%></h2>
<div class="pop-win-middle">
<div class="pop-win-body">
<div class="pop-win-content">
<div class="gray-bottom-zoom">
<div class="loading"><img id="loading_img" src="../../images/action.gif" />
<div><table align="center"><tr><td width="100%" id="title_td">正在处理,请稍后...</td></tr></table></div></div>
</div>
<div class="gray-bottom-zoom">
<h2><div class="f-right">耗用时间:<span id="clocktime">00:00:00</span></div><span><%=reportStr%></span></h2>
<table class="headblue" style="margin-left:10px;width:97.5%;">
<thead>
<tr>
<th style="width:150px"><%=preStr%><span id="pre_span">0</span></th>
<th style="width:150px"><%=addedStr%><span id="added_span">0</span></th>
<th style="width:150px"><%=failStr%><span id="failed_span">0</span></th>
<th style="width:150px"><%=processStr%><span id="process_span">0</span></th>
<th style="width:150px"><%=anotherUsedStr%><span id="another_span">0</span></th>
</tr>
</thead>
<tbody>
<tr>
<td><%=I18NMessage.getInstance().getMessage("netfocus.coreSwitchs.lyq")%><span id="router_span">0</span></td>
<td><%=I18NMessage.getInstance().getMessage("netfocus.coreSwitchs.2cjhj")%><span id="switch_span">0</span></td>
<td><%=I18NMessage.getInstance().getMessage("netfocus.coreSwitchs.3cjhj")%><span id="threelayswitch_span">0</span></td>
<td><%=I18NMessage.getInstance().getMessage("netfocus.coreSwitchs.fhq")%><span id="firewall_span">0</span></td>
<td> </td>
</tr>
<tr>
<td><%=I18NMessage.getInstance().getMessage("netfocus.coreSwitchs.wuxianap")%><span id="ap_span">0</span></td>
<td><%=I18NMessage.getInstance().getMessage("netfocus.coreSwitchs.fwq")%><span id="server_span">0</span></td>
<td><%=I18NMessage.getInstance().getMessage("netfocus.coreSwitchs.zj")%><span id="host_span">0</span></td>
<td><%=I18NMessage.getInstance().getMessage("netfocus.coreSwitchs.qt")%><span id="other_span">0</span></td>
<td> </td>
</tr>
</tbody> </table>
</div>
<div class="gray-bottom-zoom">
<h2><%=I18NMessage.getInstance().getMessage("netfocus.monitor.log")%></h2>
<iframe src="<%=path%>/modules/monitor/batchaddkmonitorframe.jsp?uid=<%=uid%>&monitorType=<%=monitorType%>" name="logsframe" frameborder="no" scrolling="no" width="100%" height="220px"></iframe> <!--
<div class="blue-scroll" id="topologdiv" style="height:200px">
<table id="logTbl" width="100%">
<tbody>
<tr>
<td width="100%" colspan="2"><%=logStr%></td>
</tr>
</tbody>
</table>
</div>
-->
</div>
</div>
</div>
</div>
<div id="d"></div>
</page:applyDecorator>
</body>
</html>
var aj = new ajax();
aj.objMode('map'); //返回一个map结构的数据,如果是list结构,aj.objMode('select'),返回一个列表,list列表每一个值内是map结构
aj.setParams("这是查询参数_pk_id:" + 39]);
aj.setDataSource("这是数据源app_query");
aj.callServer(
function () {
eval("b1=" + aj.html);
//获得map或list
// map取值写法为 b1['aaa']等
// list取值写法为 b1['list'][i]['aaa']等
//值写入
getObject('aaa').innerHTML = '所求';
}
);
};//定时启动abc()函数
setInterval(abc,1000);ajax是自己封装的js类,经试,没有出现点击不了的情况
按钮有 事件吗??如果有比如:
function out(){}把 方法 重新加入 ajax加入的内容function readlog(){
...
ajax.requet(url,callback);
...
}
callback = function(data){
addrow(data);
setTimeout(readlog,1000);
out();
}
function addrow(data){
...
}