Skip to content

Instantly share code, notes, and snippets.

@lk-geimfari
Created July 30, 2022 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lk-geimfari/48734dbebcd975cb0bad0b0e0abc853b to your computer and use it in GitHub Desktop.
Save lk-geimfari/48734dbebcd975cb0bad0b0e0abc853b to your computer and use it in GitHub Desktop.
datatables ajax
<table id="example" class="display" cellspacing="0" width="75%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Extn.</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Extn.</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
</table>
$(document).ready(function() {
$('#example').DataTable( {
"ajax": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/730692/json.txt",
"columns": [
{ "data": "name" },
{ "data": "position" },
{ "data": "office" },
{ "data": "extn" },
{ "data": "start_date" },
{ "data": "salary" }
]
} );
} );
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://cdn.datatables.net/v/dt/dt-1.10.15/datatables.min.js"></script>
<link href="https://cdn.datatables.net/v/dt/dt-1.10.15/datatables.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment