I always get error when I use table.ajax.reload()

Replies

  • pig800509pig800509 Posts: 12Questions: 2Answers: 0
    edited January 2018

    var table = window.createDataTable("#example",{
    dom: "Bfrtip",
    ajax: async function (data, callback, settings) {
    callback(
    {"data":await invokeApig({ path: "/notes" })}
    );
    console.log(await invokeApig({ path: "/notes" }));
    },
    columns: [
    { data: "noteId"},
    { data: "userId" },
    { data: "attachment" },
    { data: "content" },
    { data: "createdAt" }
    ],
    select: true,
    buttons: [
    { extend: "create", editor: editor },
    { extend: "edit", editor: editor },
    { extend: "remove", editor: editor },
    {
    text: 'Reload table',
    action: function () {
    table.ajax.reload();
    }
    }
    ]
    });

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    ajax: async function (data, callback, settings) {

    DataTables doesn't expect a Promise to be returned from that function. You need to use the callback once your invokeApig method has executed (e.g. use an internal Promise there or have it provide a callback option).

    Allan

This discussion has been closed.