jquery - Datatables server side data response error -


i getting following error when try fetch data server side script

datatables warning: table id=example - requested unknown parameter '0' row 0. more information error, please see http://datatables.net/tn/4

what doing wrong ?

here's html

<script> $(document).ready(function(){     $('#example').datatable({         serverside: true,         "columndefs": [             { "title": "sr.",           "name": "sr",           "width": "5%",  "targets": 0 },             { "title": "ecode",         "name": "code",         "width": "5%",  "targets": 1 },             { "title": "employee name", "name": "name",         "width": "25%", "targets": 2 },             { "title": "guardian",      "name": "guardian",     "width": "20%", "targets": 3 },             { "title": "doa",           "name": "doa",          "width": "10%", "targets": 4 },             { "title": "department",    "name": "department",   "width": "20%", "targets": 5 },             { "title": "designation",   "name": "designation",  "width": "20%", "targets": 6 }         ],         ajax: {             url: 'employees/listdata/all',             type: 'post'         }     }); }); </script> <table id="example" class="display" cellspacing="0" width="100%"> </table> 

here's json response

{ "recordstotal":842, "recordsfiltered":842, "data":[     {"dt_rowid":"28","sr":"1","code":"28","name":"abhishek sharma","guardian":"ramesh chand","doa":"10\/12\/2013","department":"welding shop","designation":"m. operator - nut former"},     {"dt_rowid":"66","sr":"2","code":"66","name":"achhay lal","guardian":"baharan mahto","doa":"26\/06\/2013","department":"workshop","designation":"store keeper"},     {"dt_rowid":"454","sr":"3","code":"454","name":"achhay lal","guardian":"jai kumar","doa":"26\/01\/2015","department":"cutting department","designation":"quality controller"}     ] } 

i found solution , usual simple overlooked

<script> $(document).ready(function(){     $('#example').datatable({         "processing": true,         "serverside": true,         "columndefs": [             { "data": "sr",             "title": "sr.",             "name": "sr",           "width": "5%",  "targets": 0 },             { "data": "code",           "title": "ecode",           "name": "code",         "width": "5%",  "targets": 1 },             { "data": "name",           "title": "employee name",   "name": "name",         "width": "25%", "targets": 2 },             { "data": "guardian",       "title": "guardian",        "name": "guardian",     "width": "15%", "targets": 3 },             { "data": "doa",            "title": "doa",             "name": "doa",          "width": "10%", "targets": 4 },             { "data": "department",     "title": "department",      "name": "department",   "width": "20%", "targets": 5 },             { "data": "designation",    "title": "designation",     "name": "designation",  "width": "20%", "targets": 6 }         ],         ajax: {             url: 'employees/listdata/all',             type: 'post'         }     }); }); </script> <table id="example" class="display" cellspacing="0" width="100%"></table> 

i added data property each column , worked perfectly.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -