Guest User

Untitled

a guest
May 4th, 2016
71
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ################## HTML ##################
  2. <link href="//cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css" rel="stylesheet" >
  3. <table id="example" class="display" cellspacing="0" width="100%">
  4. <thead>
  5. <tr>
  6. <th>Course</th>
  7. <th>User</th>
  8. <th>Completed</th>
  9. <th>Score</th>
  10. </tr>
  11. </thead>
  12. </table>
  13. <script src="//cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>
  14.  
  15.  
  16. ################## JavaScript ##################
  17. var table = $('#example').DataTable();
  18.  
  19. $("#testLoad").click(function(){
  20. $.post("/training/online/records",
  21. {
  22. selCID: $('#selCID').val(),
  23. csrfmiddlewaretoken: '{{ csrf_token }}'
  24. },
  25. function(data, status){
  26. alert("Data: " + data + "\nStatus: " + status);
  27. table.destroy()
  28. $('#response').html(data)
  29. $('#example').DataTable({
  30. "aaData" : data,
  31. "bProcessing" : true,
  32. "sPaginationType" : "full_numbers",
  33. "bJQueryUI" : true,
  34. "bRetrieve" : true,
  35. "bPaginate" : true,
  36. "bStateSave" : true,
  37. "bSort" : true,
  38. "aaSorting" : [[ 1, "desc" ]],
  39. "iDisplayLength" : 25,
  40. "oLanguage": {
  41. "sProcessing": "processing",
  42. "sEmptyTable": "No records found."
  43. }
  44. });
  45. });
  46. });
  47.  
  48.  
  49. ################## POST RESPONSE ##################
  50. [["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"]]
  51.  
  52. ################## ERROR ##################
  53. DataTables warning: table id=example - Requested unknown parameter '1' for row 0, column1
RAW Paste Data