ajax获取返回值两种方式

===用data,这种是通用的===

functionqueryHealthCount(){

$.ajax({

url:'${ctx}/flex!flexHealth.json',

async:false,

type:'POST',

dataType:'json',

success:function(data){

healthCount=data;

$("#zs_count").html(data);

}

});

}

===用result,这种可能是用公司后台框架返回时特有的====

//统计通知区

functionqueryMessage(){

$.ajax({

url:'${ctx}/current-alarm!queryKindsCounty.json',

type:'POST',

data:'',

async:false,

success:function(result){

$("#count1").append('');

vartable='<tablewidth="100%"border="0"cellspacing="0"cellpadding="0">';

varre=result.data;

for(vari=0;i<re.length;i++){

varkind;

varname=re[i].kinds;

vart=name.indexOf("aqgj");

varl=name.indexOf("wlgj");

varg=name.indexOf("sj");

if(parseInt(t)==0){

kind="当前安全告警"

}

if(parseInt(l)==0){

kind="当前网络报警"

}if(parseInt(g)==0){

kind="当前处理中事件";

}

table+='<trstyle="height:30px;line-height:30px;">'

+'<tdclass="msg_title"width="50%">'+kind+':</td>'

+'<tdclass="msg_count">'+re[i].cl+'(个)</td>'

+'<tdclass="msg_detal"align="right"><ahref="javascript:;"style="text-decoration:underline"onclick="doDetail();">详情</a></td>'

+'</tr>';

}

table+='</table>';

$("#count1").append(table);

}

});

}

相关推荐