Can't get datatables to work with json string
Can't get datatables to work with json string
ssuess
Posts: 2Questions: 0Answers: 0
For some reason, despite following the tutorials to the letter (at least I think I am), I can't get the following to work. It gives me the dreaded:
**DataTables warning: table id=actiontables - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4**
Here is my code, someone please tell me what I am doing wrong..
<script>
jQuery(document).ready(function(){
var myjsons =[{"one":"195","two":"thing","three":"something","four":"1481200571","five":"test string","six":"www.google.com"}];
jQuery('#actiontables').DataTable( {
data: myjsons,
columns: [
{ myjsons: 'one' },
{ myjsons: 'two' },
{ myjsons: 'three' },
{ myjsons: 'four' },
{ myjsons: 'five' },
{ myjsons: 'six' }
]
} );
}); </script>
<table id="actiontables" class="display" width="100%"></table>
This discussion has been closed.
Replies
omfg, I can't believe this. I just got it working by renaming my json "data" (from "myjsons")...what is the point of having a var if you can't name it what you want?? Hope this helps some other poor soul.
Just try this:
Try changing:
to:
Checkout this page for details:
https://datatables.net/manual/data/
Kevin