php - 将 DataTables 与 Bootstrap 主题一起使用,jQuery $.get 函数

标签 php jquery twitter-bootstrap datatables

我想使用带有 Bootstrap 主题的 DataTable 来显示我的表结果(PHP 和 SQLSRV),它将使用 jquery $.get 函数加载到 div 中。

我尝试了下面的代码,但没有成功。下面是我的 jquery 代码,如果您能在这里为我提供一些解决方案,我们将不胜感激。

标题顺序上的 CSS:

  1. Bootstrap
  2. 数据表 Bootstrap
  3. 非常棒
  4. 日期选择器
  5. 风格

页脚订单上的 JS

  1. jquery
  2. Bootstrap
  3. jquery.datatables
  4. dataTables.bootstrap
  5. 日期选择器3
  6. 自定义

    $(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/

相关文章:

php - 防止值变成负数

php - 如何在Elasticsearch索引中添加地理位置

php - 生成 PHPUnit 报告(失败和通过的测试)

javascript - 在外部 JS 执行后加载你的 JavaScript

javascript - Bootstrap Datetimepicker 设置日期

javascript - Twitter Bootstrap 的旋转木马淡入淡出过渡

php - Preg_Match 精确单词并从字符串文本中输出单词

javascript - 如果元素有类然后运行函数,否则运行另一个

javascript - Bootstrap 是否有显示隐藏类的方法?

javascript - 尝试获取行数据警报。为什么我在点击时收到多个警报?