推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
piaochen0

datatables 如何改变参数,重新获取数据?

  •  
  •   piaochen0 · Aug 2, 2019 · 3630 views
    This topic created in 2507 days ago, the information mentioned may be changed or developed.

    datatables,使用 ajax 加载数据。现在需要增加一个查询功能,要改变参数,重新提交,获取数据,在 datatables 中显示。

    datetables 配置如下: $('#query_table_problem').DataTable({
    "lengthChange": false,
    "paging": false,
    "info": false,
    "destroy": true,
    ajax: {
    url: "problem_list",
    dataSrc:'',
    type: "POST",
    data:{"status":0}
    }}

    按某个按钮执行代码,这里将 status 从 0 改成 1:
    var table_problem = $('#query_table_problem').DataTable()
    table_problem.ajax.data = {"status":1}
    table_problem.ajax.reload()

    上面的代码执行后,发现 status 参数根本没有变化,还是 0。
    向各位请教怎么解决这个问题?还是我思路有问题?

    1 replies    2019-08-02 17:52:56 +08:00
    whattheh3ll
        1
    whattheh3ll  
       Aug 2, 2019
    table_problem.settings()[0].ajax.data = {};
    table_problem.ajax.reload()
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3046 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 02:14 · PVG 10:14 · LAX 19:14 · JFK 22:14
    ♥ Do have faith in what you're doing.