我正在使用 DataTable 1.7.5 和 JQuery-1.7.1.min.js 并得到一个 JSON 解析错误。在浏览几个在线论坛时,建议升级 JQuery-1.5.1.min.js 的验证器插件,但没有关于 JQuery-1.7.1.min.js 的验证器。是否有人对此问题有任何建议?
Table HTML:
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" >
<thead>
<tr>
<th>#</th>
<th></th>
<th>Name</th>
<th>Shpr</th>
<th>Org</th>
<th>Cne</th>
<th>Dest</th>
<th>Dep Dt</th>
<th>LR No</th>
<th>Asset No</th>
<th>Curr Dt</th>
<th>Spd km/h</th>
<th>Waypoint1</th>
<th>Waypoint2</th>
<th>SDA</th>
<th>DETA</th>
<th>AMC</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Javascript:
var oTable = $('#example').dataTable({
"aLengthMenu" : [[-1, 10, 25, 50, 100], ["All", 10, 25, 50, 100]],
"iDisplayLength" : -1,
"bProcessing": true,
"bJQueryUI": true,
"bAutoWidth": false,
//"sScrollY": "300px",
"sPaginationType": "full_numbers",
"sAjaxSource": "ReportAction.do?process=home",
"bDeferRender":true,
"sDom": 'T<"clear"><"H"lfr>t<"F"ip>',
"oTableTools": {
"sSwfPath": "<%=localrequestedURL %>media/swf/copy_csv_xls_pdf.swf"
}
});
JSON数据:
result = session.createSQLQuery(sql_homepage).list();
String final_data = gson.toJson(result);
final_message = "{\"aaData\":"+final_data+"}";
1. 变量 sql_homepage 指的是对数据库的选择查询。2. 变量 final_message 被传递给将数据传递给 JSP 的动作类。