jquery ajax json 資料 遍歷
後臺返回的資料 :
{"receiveList":[{"receive_dept_id":"1007873","receive_dept_desc":"區公司領導","guid":"2016112316042622494230","receive_platform_id":"001"},{"receive_dept_id":"1007876","receive_dept_desc":"主任","guid":"2016112316042626240391","receive_platform_id":"001"}]}
其實仔細分析返回的格式,很簡單,就是一個Map,裡面放了一個List,List裡面有各種引數。
前端頁面的請求
$.ajax({
url:"/moduleAuthen/default.do?method=loadAllReceive",
dataType:"json", //返回的資料是json 格式
data:$("#fom1").serialize, //提交id為form1的所有引數
success:function(data){
var json =data.receiveList;
//第一種方式的遍歷
for(var index in json){
//其實index 就是個索引
var guid =json[index].guid;
var receive_dept_desc =json[index].receive_dept_desc;
}
//還有一種jquery 方式的遍歷,效果其實是一樣的,拿到後臺返回我們的資料,我們就可以進行各種操作了。
$.each(json,index){
var guid =json[index].guid;
var receive_dept_desc =json[index].receive_dept_desc;
}
}
})