搜索并打印json文件

时间:2015-05-15 19:09:14

标签: jquery json

employees = 
[

	{"employee" : {
	"id": "jiujsiujsd",
	"name" : "Zombies",
	"department": "design"
	}},

	{"employee" : {
	"id" : jsdffdsjsd",
	"name" : "john",
	"department": design"
	}},

	{"employee" : {
	"id" : jsdffdjhnd",
	"name" : "dave",
	"department": design"
	}}
]
		<script>
			$(document).ready(function(){
				$.getJSON('http://notionfresh.com/employees.json', function(emDepartment){
					for(var i = 0; i < employees.length; i++)
							{
							  if(employees[i].employee.department == 'design')
							  {
								return employees[i].employee.name;
							  }
							}
				});
			});
		</script>

大家好,

如何让jQuery从employees.json文件中打印出部门“设计”中员工的所有姓名?请查看上面的代码,了解到目前为止。

感谢您的帮助!

0 个答案:

没有答案