【发布时间】:2011-09-22 11:58:06
【问题描述】:
我正在尝试通过 AJAX 将 json 数据从 web2py 控制器加载到 jQuery dataTable。
但只呈现空白数据表(具有所需的格式、搜索框等)
有人可以吗?在我的代码中指出我有错误的地方。
不显示数据(由“get_data”方法返回)。
我已确保已填充数据库表。
控制器
def show_data():
return dict()
def get_data():
custdata = db.executesql(qry, as_dict=True)
return custdata
出于测试目的,我以单独的方法返回了 response.json(custdata) 并在“jsonlint.com”上验证了相同的内容。
它是有效的 json。
查看 (show_data.html)
{{extend 'layout.html'}}
$(document).ready(function() {
var oTable = $('.smarttable').dataTable( {
"sScrollY": "200px",
"sAjaxSource": "{{=URL('MIS','get_data.json')}}",
"sDom": "frtiS",
"bDeferRender": true
} );
} );
最后,为一个 class="smarttable" 的表格定义了 html 表格标签
【问题讨论】:
标签: jquery-plugins datatable web2py