jquery - Error while configuring datatable with json -



jquery - Error while configuring datatable with json -

i have table follow

<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> <thead> <tr> <th>month</th> <th>id</th> <th>comments</th> <th>details</th> </tr> </thead> <tbody> </tbody> </table>

my json is

[{ "month": "jan-2013", "id": "asdfa0", "comments": "", "details": "bla bla blba blablabalbal" }]

and script

$(document).ready(function () { var otable = $('#example').datatable({ "bprocessing": true, "sajaxsource": "script/ahd.json", "aocolumns": [ { "mdata": "month" }, { "mdata": "id" }, { "mdata": "comments" }, { "mdata": "details" } ] }); });

after doing getting next error

uncaught typeerror: cannot read property 'length' of undefined jquery.datatables.js:2649

after little googling got 1 solution wrap json in

{ aadata: [{ "month": "jan-2013", "id": "asdfa0", "comments": "", "details": "bla bla blba blablabalbal" }] }

this not working...what wrong here

reading documentation

your js must

$(document).ready(function() { $('#example').datatable( { "bprocessing": true, "bserverside": true, "sajaxsource": "script/ahd.json", "sservermethod": "post" } ); } );

and json format must

{ "secho": 3, "itotalrecords": 6, "itotaldisplayrecords": 3, "aadata": [ [ "a","b","c" ], [ "a","b","c" ], [ "a","b","c" ], [ "a","b","c" ], [ "a","b","c" ], [ "a","b","c" ], ] }

jquery plugins datatable

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -