Ajax是Java和js的异步数据交换的一门技术。
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$.ajax({
type:"get",
url:"typeServlet?state=select",
dataType:"json",
success:function(data){
$('#select').empty();
var html='';
$.each(data,function(index,comment){
html += '<tr><td>'+comment['typeID']+'</td><td>'+comment['typeName']+'</td><td><a href="typeServlet?typeID='+comment['typeID']+'&state=update">修改</a><a href="typeServlet?typeID='+comment['comment.typeID']+'&state=del">删除</a></td></tr>'
});
$('#select').html(html);
}
});
});
</script>
java必须转换成json串再发送到网页中ajax的data,回调函数中的comment是data,
comment['属性']相当于comment.属性