sAjaxSource en la tabla de datos devuelve un error

I keep on receiving this error alert = "DataTables warning (table id = 'msnc_table'): Requested unknown parameter '1' from the data source for row 0"

Aquí hay un fragmento de mi código:


  <table id="msnc_table" class="dataTable">
        <th>Customer Name</th>
         <td class="dataTables_empty">Loading data from server</td>


var msnc_table = $('#msnc_table').dataTable({
   "bProcessing": true,
   "bServerSide": true,
   "iDisplayStart": 0,
   "iDisplayLength": 11,
   "sAjaxSource": base_url+"raw/raw_ajax/get_mnsc",
   "bRetrieve": true

Función PHP

function get_mnsc()
   echo '{"sEcho":"2","iTotalRecords":20,"iTotalDisplayRecords":20,"aaData":   [["232412","12\/8\/2012","DSDA2312","Alfonso supermarket","213","231213","21312","2313","2313","2312432\r\n"],["232412","12\/8\/2012","ADS332","MCL Store","213","231213","21312","2313","2313","2312432\r\n"]]}'

preguntado el 24 de agosto de 12 a las 03:08

1 Respuestas

This kind of error from usually means there is a mismatch between the headers / columns you specify and the JSON returned from the server.

However, in your case there seem to correctly be 10 ths and 10 items in each 'row' of JSON.

Esto me hace pensar que el JSON is incorrectly formatted, o que DataTables can't process some part of it.

I'd suggest you whip open violinista y inspect the response as it actually is on client, I don't know much php, so not certain how that echo will actually appear on the client. But certainly think you should encode and set the headers e.g.

Devolver JSON desde un script PHP

You can copy that fiddler output to or para validarlo.

It may be your dates, with what look like escape characters before the slashes?, are messing it up. N.B. my dates are returned e.g.


It may be that the line breaks which look to be in wrong place in your JSON are messing it up?


Suggest you remove them entirely and see if it works, or place the break after the quotes, or after the square bracket closes?



Not sure, but certainly mod the php as per link, and use fiddler to inspect actual response if you're still having problems.

If you still have issues, then check the answer here.. may help

Good Luck ! Worth it to get working - its great !

contestado el 23 de mayo de 17 a las 12:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.