text.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>回收物列表</title>
<link rel="stylesheet" href="styles/text.css"/>
<script type="text/javascript"src="scripts/jquery.min.js"></script>
<script type="text/javascript"src="scripts/text.js"></script>
</head>
<body>
<div>
<form>
<div>
<label>请输入回收物种类</label>
<select name="selectId" id="selectId">
<option value="%">全部回收物</option>
<option value="金属回收物">金属回收物</option>
<option value="塑料回收物">塑料回收物</option>
<option value="玻璃回收物">玻璃回收物</option>
<option value="纸张回收物">纸张回收物</option>
<option value="厨余垃圾">厨余垃圾</option>
<option value="其他垃圾">其他垃圾</option>
</select>
</div>
<div>
<input type="button" value="查询" id="btSearch"/>
</div>
<br>
<br>
</form>
<div>
<table id="table-result">
<thead>
<tr>
<th>checktype_id</th>
<th>cid</th>
<th>tchek</th>
<th>content</th>
<th>cvalue</th>
<th>ctype</th>
<th>cname</th>
<th>smstemplate</th>
<th>remark</th>
</tr>
</thead>
<tbody id="tbody-result">
</tbody>
</table>
</div>
</div>
</body>
</html>
text.js页面
$(function(){
$('#btSearch').click(function(){
var selectId=$('#selectId').val();
var tbody=window.document.getElementById("tbody-result");
console.log(selectId);
$ajax({
type:"post",
dataType:"json",
url:"http://localhost:8080/work/checktype/check.do",
data:{ selectId:selectId },
success:function(msg){
if(msg.ret){
var str="";
var data=msg.data;
for(i in data){
str +="<tr>" +
"<td>" + data[i].checktype_id + "</td>" +
"<td>" + data[i].cid + "</td>" +
"<td>" + data[i].tchek + "</td>" +
"<td>" + data[i].content + "</td>" +
"<td>" + data[i].cvalue + "</td>" +
"<td>" + data[i].ctype + "</td>" +
"<td>" + data[i].cname + "</td>" +
"<td>" + data[i].smstemplate + "</td>" +
"<td>" + data[i].remark + "</td>" +
"</tr>";
}
tbody.innerHTML = str;
}
},
error: function(){ alert("查询失败")
}
});
});
});