Demo DataTables AJAX Boisvert

asd

by lun471k

HTML

<link rel="stylesheet" href="//cdn.datatables.net/1.10.7/css/jquery.dataTables.css">
<script src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
<table id="employeeList">
    <thead>
        <tr>
                <th>Name</th>
                <th>Position</th>
            </tr>
    </thead>
</table>

JavaScript

// Creating the JSON data to be received by /echo/json
$.ajax({
    method:'POST',
    url: '/echo/json',
    data: {name:"John Doe", position: "first"
    }
}).success(function(data){;

$('#employeeList').dataTable({
    data:data,
    columns:[
        {data: "name"},
        {data: "position"}
    ]
});
});