【问题标题】:Using DataTables with Bootstrap theme, jQuery $.get function使用带有 Bootstrap 主题的 DataTables,jQuery $.get 函数
【发布时间】:2014-07-08 02:21:18
【问题描述】:

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

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

标题顺序上的 CSS:

  1. 引导程序
  2. 数据表引导
  3. 太棒了
  4. 日期选择器
  5. 风格

页脚顺序的JS

  1. jquery
  2. 引导
  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();
                });
            });
        } });
    

【问题讨论】:

    标签: php jquery twitter-bootstrap datatables


    【解决方案1】:

    html() 方法只接受一个参数。它可以是 dom 对象、字符串、jQuery 对象或函数。

    您不想为您的目的使用函数,因为您想传入从 ajax 请求收到的 html

    试试这个方法

    $('.target').html(data);
    $('table').dataTable();
    

    html() API docs

    【讨论】:

    • 太棒了,如果有帮助,请随时批准答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-12
    • 2018-05-08
    • 2013-01-06
    • 1970-01-01
    • 2018-03-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多