標籤:style http os io 使用 java ar for 資料
使用ajax與iframe嵌套實現頁面局部重新整理。該javascript代碼僅供參考,需按自己需要修改。
?1. [代碼]javascript代碼
function cj_start(depname,groupid){
var urls = "<%=path%>/userGather.action";
var status = "";
var html_1 = "<iframe frameborder=\"0\" scrolling=\"no\" width=\"600\" height=\"60\" src=\"<%=basePath%>cj_status.jsp\" style=\"margin-top:3px;vertical-align: middle;\"></iframe>";
$("#cj_status_html").html(html_1);
var html_2 = "";
var cj_butoon = "";
$.ajax({
url : urls,
type:"post",
dataType:"json",
data:{depname:depname,groupid:groupid},
success : function(data){
if(data.cjstatus.length != 0){
if(data.cjstatus[0] == "0"){
cj_button = "<input type=\"button\" value=\"採集通道\" disabled=\"disabled\"/>";
$("#cj_button_html").html(cj_button);
}
for(var i = 1; i < data.cjstatus.length; i++){
html_2 += data.cjstatus[i] + " ";
}
$("#cj_status_html").html(html_2);
}else{
html_2 = "採集系統出錯,請聯絡開發人員!";
$("#cj_status_html").html(html_2);
}
}
});
}
2. [代碼]jsp的部分代碼
<tr>
<td id="cj_button_html">
<input type="button" name="caiji" value="採集通道" onclick="cj_start(‘<%=depname %>‘,‘<%=groupid %>‘);"/>
</td>
</tr>
<tr>
<td id="cj_status_html">
</td>
</tr>
3. [代碼]cj_status.jsp的代碼
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%http://www.bizhizu.cn/manhua/?
String path = request.getContextPath();漫畫圖片
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
</head>
<body>
<div>
<img src="<%=basePath %>images/loading_16x16.gif" /> <span>正在採集資料,請稍後...</span>
</div>
<script language="JavaScript">
function myrefresh()
{
window.location.reload();
}
setTimeout(‘myrefresh()‘,1000); //指定1秒重新整理一次
</script>
</body>
</html>
?
使用ajax與iframe嵌套實現頁面局部重新整理