怎么通过ajax把得到的数据遍历

如题所述

通过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;
}
});
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答