<script language="JavaScript">
window.onload = function() {
window.setInterval(showData, 5000);//每隔5s刷新数据
function showData() {
var time = (new Date()).valueOf();//加个时间戳
var xmlHttpRequest = $.post(
"${pageContext.request.contextPath}/getData?time=" + time,
null, function(data, textStatus) {
var dataInfo = eval("(" + data + ")").obj;//识别jason格式
$("#show").append(dataInfo + "<br>");
});
}
}
</script>