Invalid JSON response and Requested unknown parameter errors
Invalid JSON response and Requested unknown parameter errors
Hi
I would be grateful for some help if possible. I am returning JSON via an AJAX call and am getting the errors as per the question subject.
The first error that is shown is "Requested unknown parameter '1' for row 0, column 1 " and then an Invalid JSON response once this error is cleared
Below is my code
function populateTable(json, tableId) {
try {
var table = $('#table_' + tableId).DataTable({
"processing": true,
"serverSide": true,
"data": json.d,
"deferRender": true,
"columns:": [
{ "data": "CaseHandlerStaffNumber" },
{ "data": "RiskProfileText" },
{ "data": "AssignedCheckerStaffNumber" },
{ "data": "FeedbackUserStaffNumber" },
{ "data": "ComplaintRef" },
{ "data": "ChildComplaintRef" },
{ "data": "CaseTypeText" },
{ "data": "CheckGrade" }
]
});
} catch (e) {
}
}
I get another error message directing me to datatables.net/tn/1 however checking on JSONLint the JSON being returned is a valid response and I am not getting any 404 or 500 response when checking the returns.
I get all as 200OK
and this is an example of the JSON that is being passed in
{
"data": [{
"CaseHandlerStaffNumber": "12345678",
"RiskProfileText": "Low Risk FOS",
"AssignedCheckerStaffNumber": "77665544",
"FeedbackUserStaffNumber": null,
"ComplaintRef": "999999",
"ChildComplaintRef": "2333",
"CaseTypeText": "FOS Submission",
"CheckGrade": "Ungraded"
}]
}
I would be grateful for any help that can be offered on this thanks
Simon
This question has an accepted answers - jump to answer
Answers
sorry about the poor formatting
Hi,
With your configuration above, it suggests that your DataTable might have 9 or more columns rather than the 8 configured in Javascript. Might that be the case? They need to match.
Another point - you can't have
serverSide
enabled and not provide anajax
option. The table needs to know where to request more data from when it redraws the table. This section describes server-side and client-side processing.Allan
Hi Allan, when the headers and footers for the table is created dynamically there are only 8 columns same as the configuration I have posted.
please see the c# code below of how I am producing the tale and the JSON response.
Can you give me a link to the page or use the debugger so I can take a look at what is happening please?
Allan
Unfortunately I cant as its all internal to the location where I am working. What do you need from the debugger and I will post it here for you.
If you could give me an email address I can send you some images of what I am seeing and detail what I would expect to see.
In areas where I should see only two rows of data I am getting circa 4k rows of "", null, null .... null
and where I should see no data I am seeing
[, null, null,..... null
], null, null,..... null
ok, so the error messages have stopped, but the issue that remains is no data comes into my tables
what I have changed is
"data": json, to "data": json.d,
You can PM me the link to the debugger trace by clicking my name above and then the "Send message" button.
Allan
its an internal application so no outside access to it im afraid. im not getting anything in the debugger either that jumps out but if you tell me the steps you need me to follow I will follow them and send you the results
Allan, I am pretty much back at square one, request unknown parameter '1' for row 0 column 1.
Any ideas on what I should do as I am just going round in circles
Can you tell me the six letter debug code from the debugger please. I wasn't expecting you to use the debugger yourself! Its to give me the information that will hopefully let me answer your question.
The error you are getting means that DataTables can't find the data for column index 1 in row 0. Without knowing how your DataTable is configured, the data it is being loaded with and the HTML for the table, I'd just be guessing (and the tech note the error links to is for that).
Allan
Im not getting any errors or error codes in the debugger, just your alert window unless im looking in the wrong place.
The only thing I get up is the alert window telling me my issue
When you use the DataTables debugger, when complete it should say:
I need to know that code so I can take a look at the issue.
Allan
sorry, I thought you meant in ie, its been a long few days the code is ekazaz
Thank you. There are 12 tables in the debug trace. Which is the one you are getting error messages from. Can you also give me the exact error text please.
Allan
all of them and the error message is exactly the same for each;
"Datatables warning: table id=table_{tablenumber} - Requested unknown parameter '0' for row 0, column 0. For more information on this error please see...."
Ah!
It has a space at the end of the
data
parameter string! That makes it not the same parameter ascolumns.data
and thus it defaults to be the default data source of the column index, hence the error message.Remove that string in all of your column definitions and it should work.
Allan
we've moved forward now which is good, still the same error on various tables with data but this time its consistent with;
"Datatables warning: table id=table_{tablenumber} - Requested unknown parameter '1' for row 60 , column 1. For more information on this error please see...."
and
"Datatables warning: table id=table_{tablenumber} - Requested unknown parameter '1' for row 63 , column 1. For more information on this error please see...."
ok, so have moved on a little this morning, I am now getting an error
"Datatables warning: table id=table_{tablenumber} - Requested unknown parameter 'CaseHandlerStaffNumber' for row 0, column 0. For more information on this error please see...."
Can you give me an updated debugger link please?
Allan
I am trying to get it but I get a message saying webpage is not responding due to a long running script.
I will let you know when its done, but its been going for 10 mintues now
Its probably not going to load in that case - there is a limit on the amount of data it can upload. One option would be to create a page with a single table in it, and just a subset of the data (a single row for example) - it should fly through that and allow me to see the data for the table.
Allan
ok, I will try that
Hi sorry for the delay, the code is evemuv
you will see 12 tables on the page, but only one has been attempted to be populated. The way the original developer has coded the page to build the tables, if I disrupt that flow the page breaks...
I have tried some new things and the debug code is unipab
my new JQuery is
The issue I get now is cannot reinitialise the table_2 along with Datatables warning: table id=table_{tablenumber} - Requested unknown parameter 'CaseHandlerStaffNumber' for row 0, column 0. For more information on this error please see.
All this help is very much appreciated
The debugger shows that the parameter passed into
data
is a string:You could try using:
That will convert a string (which the server-side appears to be returning) into a valid Javascript array of objects.
Regards,
Allan
that worked along with some other little changes that I will post here in a moment
Glad to hear I could help.
Allan