2.1:
<result name="systeminfo" type="json"></result>
if(requestFlag){
$.getJSON("login/login_getSystemInfo.action",function(date){
requestFlag = false;
//alert("====="+data.cpuCombined);
$("#cpuCombined").html(data.systemInfoBean.cpuCombined);
$("#cpuUser").html(data.systemInfoBean.cpuUser);
$("#cpuSys").html(data.systemInfoBean.cpuSys);
$("#cpuIdle").html(data.systemInfoBean.cpuIdle);
$("#cpuDiv").css("width",data.systemInfoBean.cpuCombined);
$("#memTotal").html(data.systemInfoBean.memTotal);
$("#memUsed").html(data.systemInfoBean.memUsed);
$("#memFree").html(data.systemInfoBean.memFree);
$("#menFreePercentage").html(data.systemInfoBean.menFreePercentage);
$("#memDiv").css("width",data.systemInfoBean.menFreePercentage+"%");
requestFlag = true;
});
2.3:
<result name="systeminfo" type="json">
<param name="root">systemInfoBean</param>
</result>
$.getJSON("login/login_getSystemInfo.action",function(systemInfoBean){
requestFlag = false;
//alert("====="+data.cpuCombined);
$("#cpuCombined").html(systemInfoBean.cpuCombined);
$("#cpuUser").html(systemInfoBean.cpuUser);
$("#cpuSys").html(systemInfoBean.cpuSys);
$("#cpuIdle").html(systemInfoBean.cpuIdle);
$("#cpuDiv").css("width",systemInfoBean.cpuCombined);
$("#memTotal").html(systemInfoBean.memTotal);
$("#memUsed").html(systemInfoBean.memUsed);
$("#memFree").html(systemInfoBean.memFree);
$("#menFreePercentage").html(systemInfoBean.menFreePercentage);
$("#memDiv").css("width",systemInfoBean.menFreePercentage+"%");
requestFlag = true;
});
获取系统信息的前端实现
本文介绍了一种使用jQuery的getJSON方法从后端获取系统CPU和内存信息,并将其展示到前端页面上的方法。通过设置请求标志来控制数据的获取频率,确保数据的实时性和准确性。
266

被折叠的 条评论
为什么被折叠?



