我想用JSON对象填充我的JQuery表,该对象由Spring MVC返回。 我的JSON Data formate是
{
availDate: 1421508979000
custName: "Navin"
custMobile: "8765432468"
custEmail: "abc@gmail.com"
custAddress: "BAngalore"
}
我的获取数据的服务网址是 的 http://localhost:8080/HomeServiceProvider/booking/getAllBookingDetails 但我的代码无效,请检查..
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="http://cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"> </script>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css">
<script>
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "http://localhost:8080/HomeServiceProvider/booking/getAllBookingDetails" // for you it will be - /getWidgetsByType
} );
} );
</script>
</head>
<body>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>availDate</th>
<th>custName</th>
<th>Office</th>
<th>custMobile</th>
<th>custAddress</th>
</tr>
</thead>
</table>
</body>
</html>
答案 0 :(得分:0)
在数据表中添加列名及其各自的数据(JSON键值):
"columns" : [ {
"mData" : "availDate",
"bSortable" : true
}, {
"mData" : "custName",
"bSortable" : true
}, {
"mData" : "custMobile",
"bSortable" : true
}, {
"mData" : "custEmail",
"bSortable" : true
}, {
"mData" : "custAddress",
"bVisible" : false
}]
检查列{}的data table API。