on table sorting i trying to call api. but i cant show any data.

on table sorting i trying to call api. but i cant show any data.

milannakranimilannakrani Posts: 1Questions: 1Answers: 0

I have successful set data on page load. on click i trying to empty table data and redraw but i didn't show any data.

below api call i trying to connect on sorting click.

  $("#table_id").find("thead").on('click', 'th', function () {
  $.ajax({
        url: `https://run.mocky.io/v3/4b0b592a-d822-4b35-bce6-5e2aee8bf3ad?pagedata?`,
        type: "GET",
        success: function (data) {
           return JSON.stringify(data);
           table.clear().draw();
           table.rows.add(data); // Add new data
           table.columns.adjust().draw(); // Redraw the DataTable
        },
        error: function (error) {
           console.log(error);
        },
     });
  });

Answers

  • kthorngrenkthorngren Posts: 21,337Questions: 26Answers: 4,954

    on click i trying to empty table data and redraw but i didn't show any data.

    Do you get errors in the browser's console?

    Have you used the browser's network inspector to see what data is returned?

    There is nothing obvious in your code that looks like a problem. Please post a link to your page or a test can replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

Sign In or Register to comment.