JSFiddle - React, Tailwind, and code Playground

by Ashish Chopra

HTML

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.3.1/js/dataTables.buttons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.3.1/js/buttons.html5.min.js"></script>
<table id="example" class="display" cellspacing="0" width="100%">
  <thead>
    <tr>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Address</th>
    </tr>
  </thead>
</table>

JavaScript

$(document).ready(function() {
    var table = $('#example').DataTable( {
        responsive: true,
        dom: 'Bfrtip',
        buttons: [
            'excelHtml5',
            'csvHtml5',
        ],

        //data: [["Sam", "Parks","100 Main St."]]
        /*
        "ajax": function (data, callback, settings) {
          callback({"data":[["Sam", "Parks","100 Main St."]]});
        }
        */
        
        serverSide: false,
        "ajax": {
          url: "/echo/json/",
          method: 'POST',
          data: function ( d ) {
            debugger;            
            var customArray = [];
            for(i = 0; i < 5000; i++) {
              customArray.push(["[\"Sam\", \"Parks\",\"100 Main St.\"]"]);
            }
            
            customArray.join(",");
            d.json = '{"data":['+customArray+']}';
          },
          "dataSrc": function ( json ) {
            debugger;
            return json.data;
          }
        }        
    }); 
} );