ajax 自动更新页面数据

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<link rel="stylesheet" type="text/css" href="stylesheets/bootstrap-theme.min.css">
<link rel="stylesheet" type="text/css" href="stylesheets/bootstrap.min.css">
<script src="javascripts/jquery-1.11.1.min.js"></script>
<script src="javascripts/bootstrap.min.js"></script>
<style type="text/css">

body{margin:20px 20px 20px 20px}
h1, h2, h3, .masthead p, .subhead p, .marketing h2, .lead {font-family: "Helvetica Neue",Helvetica,Arial,"Microsoft Yahei UI","Microsoft YaHei",SimHei,"宋体",simsun,sans-serif;font-weight: normal;}

.show-grid [class*="span"] {
background-color: #EEEEEE;
border-radius: 3px 3px 3px 3px;
line-height: 40px;
min-height: 40px;
text-align: center;
}
.show-grid {
margin-bottom: 20px;
margin-top: 10px;
}
.show-grid [class*="span"]:hover {
background-color: #DDDDDD;
}
.show-grid [class*="span"] [class*="span"] {
background-color: #CCCCCC;
}
.show-grid .show-grid [class*="span"] {
margin-top: 5px;
}
.show-grid [class*="span"] [class*="span"] [class*="span"] {
background-color: #999999;
}

.bs-docs-example:after {
background-color: #F5F5F5;
border: 1px solid #DDDDDD;
border-radius: 4px 0 4px 0;
color: #9DA0A4;
content: "table demo:";
font-size: 12px;
font-weight: bold;
left: -1px;
padding: 3px 7px;
position: absolute;
top: -1px;
}
form.bs-docs-example {
padding-bottom: 19px;
}
.bs-docs-example {
background-color: #FFFFFF;
border: 1px solid #DDDDDD;
border-radius: 4px 4px 4px 4px;
margin: 15px 0;
padding: 39px 19px 14px;
position: relative;
}
.bs-docs-example-submenus .dropup > .dropdown-menu, .bs-docs-example-submenus .dropdown > .dropdown-menu {
display: block;
margin-bottom: 5px;
position: static;
}
.bs-docs-example-submenus {
min-height: 180px;
}
</style>
<body>
<script type="text/javascript">
setInterval(function(){update()},10000);
function update(){
$.ajax({
url: 'https://10.88.20.104/jsonStatics?',
dataType: "json",
cache: false,
jsonp:'callback', //
timeout: 5000,
success: function(data) {
tt = "";
//alert(data.length);

var $myid=$("#table table-striped");//hash table
$.each( data , function( i, item ) {

$(".table table-striped").append(
"<tr><td>" + item.id +"<td>"
+ " <td>" +item.DevN + "</td>"
+"<td>" + item.CriN + "<td>"
+"<td>" + item.ErrN + "<td>"
+"<td>" + item.WarN + "<td></tr>");
});
alert('updated');

},
error: function(jqXHR, textStatus, errorThrown) {
alert('errorXXX: ' + textStatus + " " + errorThrown);
}
});
}
</script>

<table class="table table-striped">
<thead>
<tr>
<th>Site ID</th>
<th>Device Number</th>
<th>Critical Number</th>
<th>Error Number</th>
<th>Warn Number</th>
</tr>
</thead>
<tbody>
<% for(i=0; i< userlist.length; i++) {%>
<tr><td><%= userlist[i].id %></td>
<td><%= userlist[i].DevN %></td>
<td><%= userlist[i].CriN %></td>
<td><%= userlist[i].ErrN %></td>
<td><%= userlist[i].WarN %></td>
</tr>
<% } %>


</tbody>
</table>
<!--<% for(i=0; i< userlist.length; i++) {%>-->
<!--<li><a><%= userlist[i].id %></a></li>-->
<!--<% } %>-->
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值