Display DataTable - Success function AJAX

Display DataTable - Success function AJAX

javiernbajaviernba Posts: 1Questions: 1Answers: 0

Hello friend, I need your help, I would like to show the answer the information of the result in a DataTables. I'm using the Codeigniter framework

This is my view

This is my ajax

Answers

  • kthorngrenkthorngren Posts: 5,504Questions: 19Answers: 1,226

    Where you have Print dataTables you would initialize your Datatable. You would use the --option data option to add the data to the Datatable. The data passed into success might be a JSON string which would need to be parsed into a Javascript variable. It would look something like this:

          success: function (data) {
             data = JSON.parse(data);
    
          $('#table_show2').DataTable( {
                  data: data,
          } );
          }
    

    It may take more config depending on your data structure. This page discusses data structures:
    https://datatables.net/manual/data/#Data-source-types

    Kevin

Sign In or Register to comment.