Cannot read property 'sEcho' of null

Cannot read property 'sEcho' of null

bicklpbicklp Posts: 2Questions: 2Answers: 0
edited July 2014 in Free community support

Hi

Ive just started using Server Side and am getting an error when returning the ajax call

error from chrome dev tools: Cannot read property 'sEcho' of null

The table never renders
Any ideas? Code below

this is my javascript

        var dTable = GetSearchObj('itemsTable');
        var query = GetSearchObj('query').value;

            $(dTable).html('<table cellpadding="0" cellspacing="0" border="0" class="table table-striped small-row basket-font vert-align" id="dTable"></table>');
            $('#dTable').dataTable({
                "sDom": "<'row-fluid'<'span6'T><'span6'>r>t<'row-fluid'<'span6'i><'span6'p>>",
                "iDisplayLength": 20,
                "sPaginationType": "bootstrap",
                "bAutoHeight": true,
                "aLengthMenu": [[25, 50, 100, 150, 250, 500, -1], [25, 50, 100, 150, 250, 500, "All"]],
                "bStateSave": false,
                "bPaginate": true,
                "bProcessing": true,
                "bServerSide": true,
                "bDestroy": true,
                "sAjaxSource": serviceURL + "GetServerItems",
                "aoColumns": [
                    { "mData": "itemNo", "sTitle": "Item No.", "sWidth": "120px", "sClass": "vert-align" },
                    { "mData": "Description", "sTitle": "Description", "sClass": "vert-align" },
                ],
                "fnServerParams": function (aoData) {

                    aoData.push({ "name": "iQuery", "value":  query });

                },
                "fnServerData": function (sSource, aoData, fnCallback) {
                    $.ajax({
                        "dataType": 'json',
                        "contentType": "application/json; charset=utf-8",
                        "type": "GET",
                        "url": sSource,
                        "data": aoData,
                        "success":
                                    function (msg) {

                                        var json = jQuery.parseJSON(msg.d);
                                        fnCallback(json);
                                    }
                    });
                }
            });

and this is the JSON returned form the server

{
"sEcho": 1,
"iTotalRecords": 2,
"iTotalDisplayRecords": 2,
"aaData": [
{
"itemNo": "52352",
"description": "Makita UD2500/2 240V Electric Shredder",
"unitPrice": null,
"quantity": null,
"add": null,
"stock": null,
"itemName": null,
"boxQty": null,
"brand": null,
"barcode": null,
"attributes": null,
"thumbnail": null,
"modalAdd": null
},
{
"itemNo": "MSAN2030680",
"description": "Makita Switch for Silent Shredder 12A",
"unitPrice": null,
"quantity": null,
"add": null,
"stock": null,
"itemName": null,
"boxQty": null,
"brand": null,
"barcode": null,
"attributes": null,
"thumbnail": null,
"modalAdd": null
}
]
}

This discussion has been closed.