Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ################## HTML ##################
- <link href="//cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css" rel="stylesheet" >
- <table id="example" class="display" cellspacing="0" width="100%">
- <thead>
- <tr>
- <th>Course</th>
- <th>User</th>
- <th>Completed</th>
- <th>Score</th>
- </tr>
- </thead>
- </table>
- <script src="//cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>
- ################## JavaScript ##################
- var table = $('#example').DataTable();
- $("#testLoad").click(function(){
- $.post("/training/online/records",
- {
- selCID: $('#selCID').val(),
- csrfmiddlewaretoken: '{{ csrf_token }}'
- },
- function(data, status){
- alert("Data: " + data + "\nStatus: " + status);
- table.destroy()
- $('#response').html(data)
- $('#example').DataTable({
- "aaData" : data,
- "bProcessing" : true,
- "sPaginationType" : "full_numbers",
- "bJQueryUI" : true,
- "bRetrieve" : true,
- "bPaginate" : true,
- "bStateSave" : true,
- "bSort" : true,
- "aaSorting" : [[ 1, "desc" ]],
- "iDisplayLength" : 25,
- "oLanguage": {
- "sProcessing": "processing",
- "sEmptyTable": "No records found."
- }
- });
- });
- });
- ################## POST RESPONSE ##################
- [["Course1", "demo@email.com", "2016-04-23", " 100.00"], ["Course1", "demo@email.com", "2016-03-23", " 100.00"], ["TCourse1", "demo@email.com", "2016-03-23", " 100.00"], ["Course1", "demo@email.com", "2016-03-23", " 100.00"], ["Course2", "demo@email.com", "2016-03-23", " 83.33"]]
- ################## ERROR ##################
- DataTables warning: table id=example - Requested unknown parameter '1' for row 0, column1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement