怎么通过ajax把得到的数据遍历
1个回答
展开全部
通过JSON方式返回数据,然后在success中遍历数据。操作json
$.ajax({
type: 'post',
url: "maintain_findRoomByBuildingId.shtml",
cache: false,
data: {"buildingId":buildingId},
dataType: 'json',
success: function(data){
jQuery.each(data.roomList, function(i,item){
alert(item.id+","+item.name);
});
},
error: function(){
return;
}
});
$.ajax({
type: 'post',
url: "maintain_findRoomByBuildingId.shtml",
cache: false,
data: {"buildingId":buildingId},
dataType: 'json',
success: function(data){
jQuery.each(data.roomList, function(i,item){
alert(item.id+","+item.name);
});
},
error: function(){
return;
}
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询