【问题标题】:Send additional data with data table ajax server side使用数据表ajax服务器端发送附加数据
【发布时间】:2014-02-21 11:02:02
【问题描述】:

我的脚本

<script type="text/javascript">
$(document).ready(function() {
    $('.all').dataTable( {
        "bInfo": false,
        "bProcessing": true,
        "sPaginationType": "full_numbers",
        "aLengthMenu": [[25, 50, 75, 100], [25, 50, 75, 100]],
        "iDisplayLength": 25,
        "bServerSide": true,
        "sAjaxSource": "Get_Pmob_tra",
        "bPaginate": true,
        "oLanguage": {
            "sProcessing": "<img src='gfx/ajax-loader.gif'>"
        }
    } );
} );

</script>

我正在使用数据表类来处理文件

我需要通过 ajax 调用从 html 获取新值到 PHP

我该怎么做?

【问题讨论】:

    标签: php ajax datatable jquery-datatables


    【解决方案1】:

    使用fnServerParams,像这样:

    ...
    "sAjaxSource": "Get_Pmob_tra",
    "fnServerParams": function (aoData) {
                aoData.push({ "name": "myval", "value": $('#myselect :selected').val() });
    },
    "bPaginate": true,
    ...
    

    此示例获取 id='myselect' 的选择列表的选定值,并将其作为名为 'myval' 的参数传递。在您的服务器端 Get_Pmob_tra php 代码中,从请求中获取参数:

    Request.QueryString["myval"]
    

    抱歉,这不是专门的 PHP 代码,但你明白了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-17
      • 1970-01-01
      • 1970-01-01
      • 2015-10-07
      • 1970-01-01
      • 2016-11-09
      相关资源
      最近更新 更多