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: 21,298Questions: 26Answers: 4,944

    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

This discussion has been closed.