jquery Temp jsonToAction

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="css/bootstraped.min.css" rel="stylesheet" media="screen"/>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/demo_ajax_json.js"></script>
<script src="js/jquery.tmpl.min.js"></script>
 

</head>
<body>
<form action="departmentSelect.action" class="form-search">
	部门名:<input type="text" name="departmentPVO.deptName" id="departmentQuery" class="input-medium search-query">
	<button type="button" class="btn" οnclick="ajaxQuery()">查询</button>
</form>


<input type="button" class="btn" value="新增" οnclick="location.href='toAdd.action'"/>


	 	

		<script type="text/zskx-tmpl" id="tmpl">
			<tr>
				<td>${deptId}</td>
				<td>${createTime}</td>
				<td>${modifyTime}</td>
				<td>${deptName}</td>
				<td><a href="departmentUpdate.action">修改</a>      <a href="departmentDelete.action">删除</a></td>
			</tr>
				
		</script>
 			
 		<table  class="table table-hover">
			<thead>
				<tr>
		    	<th><b>部门ID</b></th>
				<th><b>创建时间</b></th> 
				<th><b>修改时间</b></th> 
				<th><b>部门名称</b></th>
				<th><b>操作</b></th>
			</tr>
			</thead>
			<tbody id='context'>
			
			</tbody>
		</table>
	 
	 
	 
<script type="text/javascript">
    jQuery(document).ready(function($){

	   $.getJSON("departmentPVOShowJson.action",function(json){
		   
			console.log(json);
		 
			console.log($('#tmpl').tmpl(json).appendTo('#context'));

		});
	   
	   console.log("in ready...");
	});
    function ajaxQuery(){
    	var par = $("#departmentQuery").val();
    	
    	
    	
    	$.getJSON("departmentSelectJson.action?deptName="+par,function(json){
    		console.log(json);
    		$("#context").text("");
    		console.log($("#tmpl").tmpl(json).appendTo("#context"));
    	});
    }
</script>
</body>
</html




	public void showDeptJson() {
		logger.info("showDeptJson in...");
		List<DepartmentPVO> list = departmentPVOService.selectDepartment();

		JSONArray array = new JSONArray();

		for (DepartmentPVO d : list) {
			JSONObject jo = new JSONObject();
			jo.put("deptId", d.getDeptId());
			jo.put("createTime", d.getCreateTime().toString());
			jo.put("modifyTime", d.getModifyTime().toString());
			jo.put("deptName", d.getDeptName());
			array.add(jo);
		}
		
		logger.info(array.toString());
		try {
			response.setContentType("text/html");
			response.setCharacterEncoding("UTF-8");
			response.getWriter().write(array.toString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值