function getAllDeptData(){var str = "全院";var data = getDataByDept(str);alert(data);}//获取json中的数据function getDataByDept(obj){var dataset = [];$.getJSON("tourism.json",function(data){if((obj.indexOf("全院")==0 )&& ("全院".indexOf(obj) == 0)){$.each(data.provinces,function(i,info){var temp = {};temp.name = info["name"];temp.dept = info["dept"];temp.value = info["value"];dataset.push(temp);});return dataset;}else{$.each(data.provinces,function(i,info){if(info["dept"] == obj){var temp = {};temp.name = info["name"];temp.dept = info["dept"];temp.value = info["value"];dataset.push(temp);}});return dataset;}});}为什么最后打印出来的是undefined?请问我应该怎么修改呢?
添加回答
举报
0/150
提交
取消