Ajax generating Cannot read property 'error' of undefined
Ajax generating Cannot read property 'error' of undefined
lecleard
Posts: 9Questions: 2Answers: 1
This would lead me to believe that data is null. However, the datatable is populating with the data returned from my rest call. I'm not sure what I'm missing. It works without the error when I use a text file. The data in the text file is the same as that being returned from the server as I cut and pasted from the server response to test. This is how I'm building my datatable with the ajax params:
var table = $('#location').DataTable( {
'bServerSide': true,
'sAjaxDataProp': "locBase",
"sAjaxSource": "http://localhost:8080/rest/heldlocs",
'aoColumns': [
{ "mData": "locationCode" },
{ "mData": "companyName" },
{ "mData": "companyContactName" },
{ "mData": "tcpServerURL" },
{ "mData": "operatorNotes" }
]
});
Thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Posting the JSON returned from the server is a place to start. Maybe even getting debugger output.
Kevin
Note that using the legacy sAjaxSource option will drop DataTables into its legacy mode if you are using server-side processing.
ajax
is the preferred option now.Is you server-side script written for legacy or current (see the manual for details)?
Allan
Thanks Allan, the manual helped. I think I know what my issue is now.
I updated the code to the above. It works with "/src/data/heldlocs" and fails with the server call. That being said, my JSON returned from the server does not contain draw, recordsTotal, or recordsFiltered parameters. I'll add those to my response and I imagine this issue will go away.
Thanks again.
Do you actually need server-side processing? If you have less that 50'000 rows in the table, just remove the
serverSide
option.Allan