2017-04-25 93 views
0

我指的是this解决方案刷新数据表。我通过ajax调用获得了新刷新的JSON数据。但我不确定如何使用它。特别是,如何将其转换为兼容数据表aaData属性?如何使用aaData刷新数据表

success: 
    function (json){ 

    var data = json; 
    table =$(#mytable).dataTable(); 
    oSettings = table.fnSettings(); 
    table.fnClearTable(this); 

    $.each(json, function (i, item) { 
     table.oApi._fnAddData(oSettings, json[i]); 
    }); 


    oSettings.aiDisplay = oSettings.aiDisplayMaster.slice(); 
    table.fnDraw(); 
    } 

现在,我试图直接使用json [i],这给我在数据表中的错误。另外,返回的数据是一个json对象数组。

+0

刷新数据表使用Ajax [请参阅此链接](http://stackoverflow.com/questions/20141432/refresh-jquery-datatable-table) – user2841408

+0

可能重复的[刷新jQuery数据表](http:// stackoverflow.com/questions/20141432/refresh-jquery-datatable-table) –

回答

0

我从你不同的方法,但尝试一下,当你收到那么成功执行此

$("#example1").load(location.href + " #example1"); //give your table id 

这样只会刷新表,它会永远对我的作品与数据表