前端之家收集整理的这篇文章主要介绍了
JQuery Ajax动态加载Table数据的实例讲解,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_404_0@我们在jsp定义一个select和一个table,要求实现根据select的选值,动态加载table数据。
<div class="jb51code">
<pre class="brush:xhtml;">
<select id="type" name="type" onchange="reloadTable(this)">
<table id="import-table" class="table table-striped table-bordered table-hover" width="100%"></table>
' + "../../../hot/getByCode.action?code=APP",type: "post",dataType: "json",data: {}
},"scrollCollapse": true,ordering: false,visible: true,api: true,serverSide: true,columns: [{
"data": "id","class": "center","width": "80px","name": "importId",orderable: false,"title": c,"render": function(a,b,c,d) {
return getColumnReturnStr("check
Box",c.id,"importId")
}
},{
"data": "name","title": "
名称"
},],"dom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",initComplete: function() {}
});
}
$('#import-table').DataTable()
.ajax.url(
'<%=request.getContextPath()%>'+"../../../hot/getByCode.action?code="+ code
).load();
}