html页面将js引入后 js的洗发如下
$(function () { //页面加载后执行
方法(); })$(function () { //页面加载后调用iniStat方法 iniStat();})function iniStat() {//初始化方法 再调用各个当犯法 statByCounty(); //statByRate(); statByShoudNumber(); statAlreadyOpenNum(); statOpenRate(); statByBusinessType();}/** *应公开案件数 */function statByShoudNumber() { var node = new Array(); $.ajax({ type : 'post', async: false, url : 'sysadmin/report/procuratoryAnalysis/jwOpenData?type=shoudOpenNum',//请求的后台action success : function(result) { node = result; } }) $('#shoudOpenNum').html(node[0].con);//获取值根据id写进页面}/** *已公开案件数 */function statAlreadyOpenNum() { var node = new Array(); $.ajax({ type : 'post', async: false, url : 'sysadmin/report/procuratoryAnalysis/jwOpenData?type=AlreadyOpenNum', success : function(result) { node = result; } }) $('#AlreadyOpenNum').html(node[0].con);}/** * 公开率 */function statOpenRate() { var already=$('#AlreadyOpenNum').text(); var should= $('#shoudOpenNum').text();$('#openRate').html(((already/should)*100).toFixed(2)+"%");//js求半分比 求余两位数的方法}