【发布时间】:2015-05-15 06:25:24
【问题描述】:
找到了很多解决方案,但没有一个对我有用。谁能告诉我这段代码有什么问题?
我的桌子是这样的
<table id="allPermission" class=" table-striped" cellspacing="0" width="100%">
<thead>
<tr>
<th>Permission No</th>
<th>Permission</th>
<th>Command</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<th>Permission No</th>
<th>Permission</th>
<th>Command</th>
</tr>
</tfoot>
</table>
我的java脚本代码在这里
var tbl = $('#allPermission').DataTable({
"processing": true,
"retrieve": true,
"serverSide": true,
"lengthMenu": [
[5, 10, 25, -1],
[5, 10, 25, "All"]
],
"ajax": $.fn.dataTable.pipeline({
url: 'rest/showAllPermissions',
pages: 2 // number of pages to cache
}),
"columns": [{
"data": "permid"
}, {
"data": "permissionname"
}, {
"data": "DT_RowId",
"sortable": false,
"render": function(data, type, full) {
var result = "";
result = '<a class="btn btn-info btn-sm" href=/fieldforce/user/editAdmin/' + full.dt_RowId + ' style="width: 58px;"' + '>' + 'Edit' + '</a>' + '<a class="btn btn-danger btn-sm" href=/fieldforce/user/deleteAdmin/' + full.dt_RowId + ' style="margin-left: 15px;"' + '>' + 'Delete' + '</a>';
return result;
}
}],
"deferRender": true,
"scrollY": "250px"
});
$('#addPerm').submit(function(e) {
e.preventDefault();
$('#loadingGif').css({
"display": "block"
});
$('#formBody').css({
"display": "none"
});
// do ajax submition
$.ajax({
url: "/fieldforce/administration/rest/addPermission",
type: "POST",
data: $(this).serialize(),
success: function(data, status, xhr) {
$('#loadingGif').css({
"display": "none"
});
// $('#addPermission').modal('toggle');
$('#messageBody').html("Success");
tbl.row.add({
"permid": '9',
"permissionname": 'admin',
"DT_RowId": '8'
}).draw();
},
error: function(jqXHR, textStatus, errorThrown) {
$('#messageBody').html("Server Error");
}
});
});
我正在使用 jquery 版本 jquery-1.11.1.min 和数据表版本是 //cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js TIA
【问题讨论】:
-
你遇到了什么错误?
-
调试时没有错误显示。但行不加
-
@Amir 查看我编辑的答案
标签: javascript jquery datatables