我想使用带有 Bootstrap 主题的 DataTable 来显示我的表结果(PHP 和 SQLSRV),它将使用 jquery $.get 函数加载到 div 中。
我尝试了下面的代码,但没有成功。下面是我的 jquery 代码,如果您能在这里为我提供一些解决方案,我们将不胜感激。
标题顺序上的 CSS:
- Bootstrap
- 数据表 Bootstrap
- 非常棒
- 日期选择器
- 风格
页脚订单上的 JS
- jquery
- Bootstrap
- jquery.datatables
- dataTables.bootstrap
- 日期选择器3
自定义
$(document).ready(function () { $("#getData").on('click', function () { var report = $(this).val(); if (report == 'tput') { var tputpage = 'reports/dtput.php', dstrt = $('#from_date').val(), dend = $('#to_date').val(); $.get(tputpage, { dstrt:dstrt, dend:dend }, function (data) { $('.target').html(data,function(){ $('table').dataTable(); }); }); } });
最佳答案
html()
方法仅接受一个参数。它可以是 dom 对象、字符串、jQuery 对象或函数。
您不需要函数来实现您的目的,因为您想传递从 ajax 请求收到的 html
尝试这样做
$('.target').html(data);
$('table').dataTable();
<强> html() API docs
关于php - 将 DataTables 与 Bootstrap 主题一起使用,jQuery $.get 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24622745/