webapi returns datatable and get data using ajax giving error
webapi returns datatable and get data using ajax giving error
schinamanagonda
Posts: 38Questions: 5Answers: 0
i cannot define columns or headers it just returns datatable and convert that to datatable in the frontend
Answers
Sorry but your problem description isn't detailed enough to understand the problem to help.
Please provide more details including any error messages so we can offer suggestions. Post your Datatables init code. Better is a link to your page or test case replicating the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
webapi get datatable because it creates dynamic columns and dynamic header. in
ajax query
$('#actualTable').DataTable( {
ajax: {
"url": 'http://localhost:64158/ProductionEfficiencyReport/GetActualTable',
},
});
but still get error the returned data shows
[
{"Id":0,"Line":"PAIL3","1-Dec":14240.0,"2-Dec":null,"3-Dec":null,"4-Dec":6300.0,"5-Dec":14040.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,
"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,
"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null
}
,{"Id":1,"Line":"DRLN1","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":0.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":2,"Line":"DRLN5","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":0.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":3,"Line":"DRLN6","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":5500.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":4,"Line":"LN03 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":0.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":5,"Line":"LN20 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":8662.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":6,"Line":"LN6 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":6894.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":7,"Line":"LN7 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":4092.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":8,"Line":"LN9 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":0.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":9,"Line":"PAIL2","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":7440.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":10,"Line":"LN2 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":2310.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,
"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,
"30-Dec":null,"31-Dec":null}]
You have a top level array of data. See this example for how to configure for that.
You also have object based data. See the manual for how to configure for that.
Allan
i know to use the above examples. but i cannot give the column names because that should be changed for every month so please help me
Use
columns.title
to define the header names.See this FAQ for getting the column names via ajax - assuming that is what you want to do.
Kevin
in the above example too how can i say the column null ? if u see above the data is monthly data every month the column headers change
I'm not sure I understand the question.
You can use a variable to define the columns. You can programmatically define the columns based on the current month. Use something like this example to get the current month name:
https://www.w3schools.com/jsref/jsref_getmonth.asp
Then use that name to define the columns then apply to Datatables, for example:
You can use a loop to build the columns variable.
If this doesn't help then please provide more specifics of what you are asking for. One or two sentences is not enough for me to understand what you want.
Kevin
This example shows one option to fetch the columns via
$.ajax()
, as suggested in the FAQ:https://live.datatables.net/huyexejo/1800/edit
It gets the column names from the column object key. You could also return the columns names in a separate object.
Kevin
Thanks this is so helpful but still why do i get this error when i try to click the url the data shows up
You will need to investigate what is returned by the server. Use the browser's network inspector. This SO thread might give some ideas.
Kevin
I changed everything but i get this error now
this is my javascript method
below is the table
Can you show me the JSON response from the server please? You might need to use
ajax.dataSrc
set to be an empty string (you will if the server is returning a top level array).Allan
i added the response before too
[
{"Id":0,"Line":"PAIL3","1-Dec":14240.0,"2-Dec":null,"3-Dec":null,"4-Dec":6300.0,"5-Dec":14040.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,
"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,
"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null
}
,{"Id":1,"Line":"DRLN1","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":0.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":2,"Line":"DRLN5","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":0.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":3,"Line":"DRLN6","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":5500.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":4,"Line":"LN03 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":0.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":5,"Line":"LN20 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":8662.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":6,"Line":"LN6 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":6894.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":7,"Line":"LN7 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":4092.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":8,"Line":"LN9 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":0.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":9,"Line":"PAIL2","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":7440.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":10,"Line":"LN2 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":2310.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,
"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,
"30-Dec":null,"31-Dec":null}
]
this is the url method
List<string> tableNames = context.Database.SqlQuery<string>("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES " +
"WHERE TABLE_TYPE = 'BASE TABLE'").ToList();
string currentTableName = ""; string tableName = "";
currentTableName = string.Format("TargetDailyData_{0}_{1}", DateTime.Now.Year, DateTime.Now.ToString("MMM"));
tableName = tableNames.Find(s => s.Trim().Equals(currentTableName));
string query = string.Format("SELECT * FROM {0}", tableName);
DataTable dataTable = new DataTable();
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnectionString"].
ConnectionString.ToString()))
{
connection.Open();
using (SqlCommand command = new SqlCommand(query, connection))
{
using (SqlDataAdapter adapter = new SqlDataAdapter(command))
{
adapter.Fill(dataTable);
}
}
}
return dataTable;
Have you used the
ajax.dataSrc
setting that Allan suggested, like this example?There isn't an obvious issue from the JSON response you posted. Is the JSON response you posted from the browser's network inspector? If not please use the browser's network inspector to get the JSON response to post here.
If you can't post a link to your page so we can take a look maybe the debugger can provide Allan enough information to help.
Kevin
yes i tried that
$('#actualTable').DataTable( {
ajax: {
"url": 'http://localhost:64158/ProductionEfficiencyReport/GetActualTable',
"dataType": "jsonp",
"dataSrc":""
},
columns:columns
});
I would have expected that to work. If it isn't working for you, please link to a test case showing the issue so I can help to debug it.
Allan
[{
"Id": 0,
"Line": "PAIL3",
"1-Dec": 14240.0,
"2-Dec": null,
"3-Dec": null,
"4-Dec": 6300.0,
"5-Dec": 14040.0,
"6-Dec": 0.0,
"7-Dec": 0.0,
"8-Dec": 0.0,
"9-Dec": null,
"10-Dec": null,
"11-Dec": null,
"12-Dec": 0.0,
"13-Dec": 0.0,
"14-Dec": 0.0,
"15-Dec": 0.0,
"16-Dec": null,
"17-Dec": null,
"18-Dec": null,
"19-Dec": null,
"20-Dec": null,
"21-Dec": null,
"22-Dec": null,
"23-Dec": null,
"24-Dec": null,
"25-Dec": null,
"26-Dec": null,
"27-Dec": null,
"28-Dec": null,
"29-Dec": null,
"30-Dec": null,
"31-Dec": null
}, {
"Id": 1,
"Line": "DRLN1",
"1-Dec": null,
"2-Dec": null,
"3-Dec": null,
"4-Dec": null,
"5-Dec": 0.0,
"6-Dec": 0.0,
"7-Dec": 0.0,
"8-Dec": 0.0,
"9-Dec": null,
"10-Dec": null,
"11-Dec": null,
"12-Dec": 0.0,
"13-Dec": 0.0,
"14-Dec": 0.0,
"15-Dec": 0.0,
"16-Dec": null,
"17-Dec": null,
"18-Dec": null,
"19-Dec": null,
"20-Dec": null,
"21-Dec": null,
"22-Dec": null,
"23-Dec": null,
"24-Dec": null,
"25-Dec": null,
"26-Dec": null,
"27-Dec": null,
"28-Dec": null,
"29-Dec": null,
"30-Dec": null,
"31-Dec": null
}, {
"Id": 2,
"Line": "DRLN5",
"1-Dec": null,
"2-Dec": null,
"3-Dec": null,
"4-Dec": null,
"5-Dec": 0.0,
"6-Dec": 0.0,
"7-Dec": 0.0,
"8-Dec": 0.0,
"9-Dec": null,
"10-Dec": null,
"11-Dec": null,
"12-Dec": null,
"13-Dec": null,
"14-Dec": null,
"15-Dec": null,
"16-Dec": null,
"17-Dec": null,
"18-Dec": null,
"19-Dec": null,
"20-Dec": null,
"21-Dec": null,
"22-Dec": null,
"23-Dec": null,
"24-Dec": null,
"25-Dec": null,
"26-Dec": null,
"27-Dec": null,
"28-Dec": null,
"29-Dec": null,
"30-Dec": null,
"31-Dec": null
}, {
"Id": 3,
"Line": "DRLN6",
"1-Dec": null,
"2-Dec": null,
"3-Dec": null,
"4-Dec": null,
"5-Dec": 5500.0,
"6-Dec": 0.0,
"7-Dec": 0.0,
"8-Dec": 0.0,
"9-Dec": null,
"10-Dec": null,
"11-Dec": null,
"12-Dec": 0.0,
"13-Dec": 0.0,
"14-Dec": 0.0,
"15-Dec": 0.0,
"16-Dec": null,
"17-Dec": null,
"18-Dec": null,
"19-Dec": null,
"20-Dec": null,
"21-Dec": null,
"22-Dec": null,
"23-Dec": null,
"24-Dec": null,
"25-Dec": null,
"26-Dec": null,
"27-Dec": null,
"28-Dec": null,
"29-Dec": null,
"30-Dec": null,
"31-Dec": null
}, {
"Id": 4,
"Line": "LN03 ",
"1-Dec": null,
"2-Dec": null,
"3-Dec": null,
"4-Dec": null,
"5-Dec": 0.0,
"6-Dec": 0.0,
"7-Dec": 0.0,
"8-Dec": 0.0,
"9-Dec": null,
"10-Dec": null,
"11-Dec": null,
"12-Dec": null,
"13-Dec": null,
"14-Dec": null,
"15-Dec": null,
"16-Dec": null,
"17-Dec": null,
"18-Dec": null,
"19-Dec": null,
"20-Dec": null,
"21-Dec": null,
"22-Dec": null,
"23-Dec": null,
"24-Dec": null,
"25-Dec": null,
"26-Dec": null,
"27-Dec": null,
"28-Dec": null,
"29-Dec": null,
"30-Dec": null,
"31-Dec": null
}, {
"Id": 5,
"Line": "LN20 ",
"1-Dec": null,
"2-Dec": null,
"3-Dec": null,
"4-Dec": null,
"5-Dec": 8662.0,
"6-Dec": 0.0,
"7-Dec": 0.0,
"8-Dec": 0.0,
"9-Dec": null,
"10-Dec": null,
"11-Dec": null,
"12-Dec": 0.0,
"13-Dec": 0.0,
"14-Dec": 0.0,
"15-Dec": 0.0,
"16-Dec": null,
"17-Dec": null,
"18-Dec": null,
"19-Dec": null,
"20-Dec": null,
"21-Dec": null,
"22-Dec": null,
"23-Dec": null,
"24-Dec": null,
"25-Dec": null,
"26-Dec": null,
"27-Dec": null,
"28-Dec": null,
"29-Dec": null,
"30-Dec": null,
"31-Dec": null
}, {
"Id": 6,
"Line": "LN6 ",
"1-Dec": null,
"2-Dec": null,
"3-Dec": null,
"4-Dec": null,
"5-Dec": 6894.0,
"6-Dec": 0.0,
"7-Dec": 0.0,
"8-Dec": 0.0,
"9-Dec": null,
"10-Dec": null,
"11-Dec": null,
"12-Dec": 0.0,
"13-Dec": 0.0,
"14-Dec": 0.0,
"15-Dec": 0.0,
"16-Dec": null,
"17-Dec": null,
"18-Dec": null,
"19-Dec": null,
"20-Dec": null,
"21-Dec": null,
"22-Dec": null,
"23-Dec": null,
"24-Dec": null,
"25-Dec": null,
"26-Dec": null,
"27-Dec": null,
"28-Dec": null,
"29-Dec": null,
"30-Dec": null,
"31-Dec": null
}, {
"Id": 7,
"Line": "LN7 ",
"1-Dec": null,
"2-Dec": null,
"3-Dec": null,
"4-Dec": null,
"5-Dec": 4092.0,
"6-Dec": 0.0,
"7-Dec": 0.0,
"8-Dec": 0.0,
"9-Dec": null,
"10-Dec": null,
"11-Dec": null,
"12-Dec": 0.0,
"13-Dec": 0.0,
"14-Dec": 0.0,
"15-Dec": 0.0,
"16-Dec": null,
"17-Dec": null,
"18-Dec": null,
"19-Dec": null,
"20-Dec": null,
"21-Dec": null,
"22-Dec": null,
"23-Dec": null,
"24-Dec": null,
"25-Dec": null,
"26-Dec": null,
"27-Dec": null,
"28-Dec": null,
"29-Dec": null,
"30-Dec": null,
"31-Dec": null
}, {
"Id": 8,
"Line": "LN9 ",
"1-Dec": null,
"2-Dec": null,
"3-Dec": null,
"4-Dec": null,
"5-Dec": 0.0,
"6-Dec": 0.0,
"7-Dec": 0.0,
"8-Dec": 0.0,
"9-Dec": null,
"10-Dec": null,
"11-Dec": null,
"12-Dec": 0.0,
"13-Dec": 0.0,
"14-Dec": 0.0,
"15-Dec": 0.0,
"16-Dec": null,
"17-Dec": null,
"18-Dec": null,
"19-Dec": null,
"20-Dec": null,
"21-Dec": null,
"22-Dec": null,
"23-Dec": null,
"24-Dec": null,
"25-Dec": null,
"26-Dec": null,
"27-Dec": null,
"28-Dec": null,
"29-Dec": null,
"30-Dec": null,
"31-Dec": null
}, {
"Id": 9,
"Line": "PAIL2",
"1-Dec": null,
"2-Dec": null,
"3-Dec": null,
"4-Dec": null,
"5-Dec": 7440.0,
"6-Dec": 0.0,
"7-Dec": 0.0,
"8-Dec": 0.0,
"9-Dec": null,
"10-Dec": null,
"11-Dec": null,
"12-Dec": 0.0,
"13-Dec": 0.0,
"14-Dec": 0.0,
"15-Dec": 0.0,
"16-Dec": null,
"17-Dec": null,
"18-Dec": null,
"19-Dec": null,
"20-Dec": null,
"21-Dec": null,
"22-Dec": null,
"23-Dec": null,
"24-Dec": null,
"25-Dec": null,
"26-Dec": null,
"27-Dec": null,
"28-Dec": null,
"29-Dec": null,
"30-Dec": null,
"31-Dec": null
}, {
"Id": 10,
"Line": "LN2 ",
"1-Dec": null,
"2-Dec": null,
"3-Dec": null,
"4-Dec": null,
"5-Dec": 2310.0,
"6-Dec": 0.0,
"7-Dec": 0.0,
"8-Dec": 0.0,
"9-Dec": null,
"10-Dec": null,
"11-Dec": null,
"12-Dec": 0.0,
"13-Dec": 0.0,
"14-Dec": 0.0,
"15-Dec": 0.0,
"16-Dec": null,
"17-Dec": null,
"18-Dec": null,
"19-Dec": null,
"20-Dec": null,
"21-Dec": null,
"22-Dec": null,
"23-Dec": null,
"24-Dec": null,
"25-Dec": null,
"26-Dec": null,
"27-Dec": null,
"28-Dec": null,
"29-Dec": null,
"30-Dec": null,
"31-Dec": null
}]
this is the response from browser
Do you get any errors, either alerts or in the console?
In your last code snippet you have
"dataType": "jsonp",
. But it doesn't look like your server is responding with a JSONP response as it should also contain a function name. Use the browser's network inspector to see the request payload and response. You will see both are wrapped in a function, something like thisjQuery37007004015063149109_1702421439731({ ... })
. Maybe your server doesn't support JSONP or you need to enable it if you want to use it.Or, remove
"dataType": "jsonp",
if your server doesn't support it.Its difficult to troubleshoot this problem because you post a code snippet or JSON response without details of your current Datatables configuration and what errors you are getting. This is why we are asking for a link to your page or test case that replicates the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
{\"Id\":0,\"Line\":\"PAIL3\",\"1-Dec\":14240.0,\"2-Dec\":null,\"3-Dec\":null,\"4-Dec\":6300.0,\"5-Dec\":14040.0,\"6-Dec\":0.0,\"7-Dec\":0.0,\"8-Dec\":0.0,\"9-Dec\":null,\"10-Dec\":null,\"11-Dec\":null,\"12-Dec\":0.0,\"13-Dec\":0.0,\"14-Dec\":0.0,\"15-Dec\":0.0,\"16-Dec\":null,\"17-Dec\":null,\"18-Dec\":null,\"19-Dec\":null,\"20-Dec\":null,\"21-Dec\":null,\"22-Dec\":null,\"23-Dec\":null,\"24-Dec\":null,\"25-Dec\":null,\"26-Dec\":null,\"27-Dec\":null,\"28-Dec\":null,\"29-Dec\":null,\"30-Dec\":null,\"31-Dec\":null},{\"Id\":1,\"Line\":\"DRLN1\",\"1-Dec\":null,\"2-Dec\":null,\"3-Dec\":null,\"4-Dec\":null,\"5-Dec\":0.0,\"6-Dec\":0.0,\"7-Dec\":0.0,\"8-Dec\":0.0,\"9-Dec\":null,\"10-Dec\":null,\"11-Dec\":null,\"12-Dec\":0.0,\"13-Dec\":0.0,\"14-Dec\":0.0,\"15-Dec\":0.0,\"16-Dec\":null,\"17-Dec\":null,\"18-Dec\":null,\"19-Dec\":null,\"20-Dec\":null,\"21-Dec\":null,\"22-Dec\":null,\"23-Dec\":null,\"24-Dec\":null,\"25-Dec\":null,\"26-Dec\":null,\"27-Dec\":null,\"28-Dec\":null,\"29-Dec\":null,\"30-Dec\":null,\"31-Dec\":null},{\"Id\":2,\"Line\":\"DRLN5\",\"1-Dec\":null,\"2-Dec\":null,\"3-Dec\":null,\"4-Dec\":null,\"5-Dec\":0.0,\"6-Dec\":0.0,\"7-Dec\":0.0,\"8-Dec\":0.0,\"9-Dec\":null,\"10-Dec\":null,\"11-Dec\":null,\"12-Dec\":null,\"13-Dec\":null,\"14-Dec\":null,\"15-Dec\":null,\"16-Dec\":null,\"17-Dec\":null,\"18-Dec\":null,\"19-Dec\":null,\"20-Dec\":null,\"21-Dec\":null,\"22-Dec\":null,\"23-Dec\":null,\"24-Dec\":null,\"25-Dec\":null,\"26-Dec\":null,\"27-Dec\":null,\"28-Dec\":null,\"29-Dec\":null,\"30-Dec\":null,\"31-Dec\":null},{\"Id\":3,\"Line\":\"DRLN6\",\"1-Dec\":null,\"2-Dec\":null,\"3-Dec\":null,\"4-Dec\":null,\"5-Dec\":5500.0,\"6-Dec\":0.0,\"7-Dec\":0.0,\"8-Dec\":0.0,\"9-Dec\":null,\"10-Dec\":null,\"11-Dec\":null,\"12-Dec\":0.0,\"13-Dec\":0.0,\"14-Dec\":0.0,\"15-Dec\":0.0,\"16-Dec\":null,\"17-Dec\":null,\"18-Dec\":null,\"19-Dec\":null,\"20-Dec\":null,\"21-Dec\":null,\"22-Dec\":null,\"23-Dec\":null,\"24-Dec\":null,\"25-Dec\":null,\"26-Dec\":null,\"27-Dec\":null,\"28-Dec\":null,\"29-Dec\":null,\"30-Dec\":null,\"31-Dec\":null},{\"Id\":4,\"Line\":\"LN03 \",\"1-Dec\":null,\"2-Dec\":null,\"3-Dec\":null,\"4-Dec\":null,\"5-Dec\":0.0,\"6-Dec\":0.0,\"7-Dec\":0.0,\"8-Dec\":0.0,\"9-Dec\":null,\"10-Dec\":null,\"11-Dec\":null,\"12-Dec\":null,\"13-Dec\":null,\"14-Dec\":null,\"15-Dec\":null,\"16-Dec\":null,\"17-Dec\":null,\"18-Dec\":null,\"19-Dec\":null,\"20-Dec\":null,\"21-Dec\":null,\"22-Dec\":null,\"23-Dec\":null,\"24-Dec\":null,\"25-Dec\":null,\"26-Dec\":null,\"27-Dec\":null,\"28-Dec\":null,\"29-Dec\":null,\"30-Dec\":null,\"31-Dec\":null},{\"Id\":5,\"Line\":\"LN20 \",\"1-Dec\":null,\"2-Dec\":null,\"3-Dec\":null,\"4-Dec\":null,\"5-Dec\":8662.0,\"6-Dec\":0.0,\"7-Dec\":0.0,\"8-Dec\":0.0,\"9-Dec\":null,\"10-Dec\":null,\"11-Dec\":null,\"12-Dec\":0.0,\"13-Dec\":0.0,\"14-Dec\":0.0,\"15-Dec\":0.0,\"16-Dec\":null,\"17-Dec\":null,\"18-Dec\":null,\"19-Dec\":null,\"20-Dec\":null,\"21-Dec\":null,\"22-Dec\":null,\"23-Dec\":null,\"24-Dec\":null,\"25-Dec\":null,\"26-Dec\":null,\"27-Dec\":null,\"28-Dec\":null,\"29-Dec\":null,\"30-Dec\":null,\"31-Dec\":null},{\"Id\":6,\"Line\":\"LN6 \",\"1-Dec\":null,\"2-Dec\":null,\"3-Dec\":null,\"4-Dec\":null,\"5-Dec\":6894.0,\"6-Dec\":0.0,\"7-Dec\":0.0,\"8-Dec\":0.0,\"9-Dec\":null,\"10-Dec\":null,\"11-Dec\":null,\"12-Dec\":0.0,\"13-Dec\":0.0,\"14-Dec\":0.0,\"15-Dec\":0.0,\"16-Dec\":null,\"17-Dec\":null,\"18-Dec\":null,\"19-Dec\":null,\"20-Dec\":null,\"21-Dec\":null,\"22-Dec\":null,\"23-Dec\":null,\"24-Dec\":null,\"25-Dec\":null,\"26-Dec\":null,\"27-Dec\":null,\"28-Dec\":null,\"29-Dec\":null,\"30-Dec\":null,\"31-Dec\":null},{\"Id\":7,\"Line\":\"LN7 \",\"1-Dec\":null,\"2-Dec\":null,\"3-Dec\":null,\"4-Dec\":null,\"5-Dec\":4092.0,\"6-Dec\":0.0,\"7-Dec\":0.0,\"8-Dec\":0.0,\"9-Dec\":null,\"10-Dec\":null,\"11-Dec\":null,\"12-Dec\":0.0,\"13-Dec\":0.0,\"14-Dec\":0.0,\"15-Dec\":0.0,\"16-Dec\":null,\"17-Dec\":null,\"18-Dec\":null,\"19-Dec\":null,\"20-Dec\":null,\"21-Dec\":null,\"22-Dec\":null,\"23-Dec\":null,\"24-Dec\":null,\"25-Dec\":null,\"26-Dec\":null,\"27-Dec\":null,\"28-Dec\":null,\"29-Dec\":null,\"30-Dec\":null,\"31-Dec\":null},{\"Id\":8,\"Line\":\"LN9 \",\"1-Dec\":null,\"2-Dec\":null,\"3-Dec\":null,\"4-Dec\":null,\"5-Dec\":0.0,\"6-Dec\":0.0,\"7-Dec\":0.0,\"8-Dec\":0.0,\"9-Dec\":null,\"10-Dec\":null,\"11-Dec\":null,\"12-Dec\":0.0,\"13-Dec\":0.0,\"14-Dec\":0.0,\"15-Dec\":0.0,\"16-Dec\":null,\"17-Dec\":null,\"18-Dec\":null,\"19-Dec\":null,\"20-Dec\":null,\"21-Dec\":null,\"22-Dec\":null,\"23-Dec\":null,\"24-Dec\":null,\"25-Dec\":null,\"26-Dec\":null,\"27-Dec\":null,\"28-Dec\":null,\"29-Dec\":null,\"30-Dec\":null,\"31-Dec\":null},{\"Id\":9,\"Line\":\"PAIL2\",\"1-Dec\":null,\"2-Dec\":null,\"3-Dec\":null,\"4-Dec\":null,\"5-Dec\":7440.0,\"6-Dec\":0.0,\"7-Dec\":0.0,\"8-Dec\":0.0,\"9-Dec\":null,\"10-Dec\":null,\"11-Dec\":null,\"12-Dec\":0.0,\"13-Dec\":0.0,\"14-Dec\":0.0,\"15-Dec\":0.0,\"16-Dec\":null,\"17-Dec\":null,\"18-Dec\":null,\"19-Dec\":null,\"20-Dec\":null,\"21-Dec\":null,\"22-Dec\":null,\"23-Dec\":null,\"24-Dec\":null,\"25-Dec\":null,\"26-Dec\":null,\"27-Dec\":null,\"28-Dec\":null,\"29-Dec\":null,\"30-Dec\":null,\"31-Dec\":null},{\"Id\":10,\"Line\":\"LN2 \",\"1-Dec\":null,\"2-Dec\":null,\"3-Dec\":null,\"4-Dec\":null,\"5-Dec\":2310.0,\"6-Dec\":0.0,\"7-Dec\":0.0,\"8-Dec\":0.0,\"9-Dec\":null,\"10-Dec\":null,\"11-Dec\":null,\"12-Dec\":0.0,\"13-Dec\":0.0,\"14-Dec\":0.0,\"15-Dec\":0.0,\"16-Dec\":null,\"17-Dec\":null,\"18-Dec\":null,\"19-Dec\":null,\"20-Dec\":null,\"21-Dec\":null,\"22-Dec\":null,\"23-Dec\":null,\"24-Dec\":null,\"25-Dec\":null,\"26-Dec\":null,\"27-Dec\":null,\"28-Dec\":null,\"29-Dec\":null,\"30-Dec\":null,\"31-Dec\":null}
with the networkinspector log i think this is the data it is giving me back
The backslashes in front of the double quotes (
\"
) suggest that the response is being JSON encoded twice by your server code. The second JSON encoding is escaping the double quotes.It might be a copy and paste error but the row data needs to be in an array, so it should look like this without the escaped quotes and in an array:
Check the server script to see where the data is being encapsulated twice. Otherwise use
ajax.dataSrc
as a function, see last example in the docs, to use JSON.parse() to decapsulate the data.Kevin
jsonp cannot be removed i was getting 200 ok response and i tried to convert in to string and changed the url but still i get error
[{"Id":0,"Line":"PAIL3","1-Dec":14240.0,"2-Dec":null,"3-Dec":null,"4-Dec":6300.0,"5-Dec":14040.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":0.0,"13-Dec":0.0,"14-Dec":0.0,"15-Dec":0.0,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":1,"Line":"DRLN1","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":0.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":0.0,"13-Dec":0.0,"14-Dec":0.0,"15-Dec":0.0,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":2,"Line":"DRLN5","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":0.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":3,"Line":"DRLN6","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":5500.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":0.0,"13-Dec":0.0,"14-Dec":0.0,"15-Dec":0.0,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":4,"Line":"LN03 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":0.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":null,"13-Dec":null,"14-Dec":null,"15-Dec":null,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":5,"Line":"LN20 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":8662.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":0.0,"13-Dec":0.0,"14-Dec":0.0,"15-Dec":0.0,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":6,"Line":"LN6 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":6894.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":0.0,"13-Dec":0.0,"14-Dec":0.0,"15-Dec":0.0,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":7,"Line":"LN7 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":4092.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":0.0,"13-Dec":0.0,"14-Dec":0.0,"15-Dec":0.0,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":8,"Line":"LN9 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":0.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":0.0,"13-Dec":0.0,"14-Dec":0.0,"15-Dec":0.0,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":9,"Line":"PAIL2","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":7440.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":0.0,"13-Dec":0.0,"14-Dec":0.0,"15-Dec":0.0,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null},{"Id":10,"Line":"LN2 ","1-Dec":null,"2-Dec":null,"3-Dec":null,"4-Dec":null,"5-Dec":2310.0,"6-Dec":0.0,"7-Dec":0.0,"8-Dec":0.0,"9-Dec":null,"10-Dec":null,"11-Dec":null,"12-Dec":0.0,"13-Dec":0.0,"14-Dec":0.0,"15-Dec":0.0,"16-Dec":null,"17-Dec":null,"18-Dec":null,"19-Dec":null,"20-Dec":null,"21-Dec":null,"22-Dec":null,"23-Dec":null,"24-Dec":null,"25-Dec":null,"26-Dec":null,"27-Dec":null,"28-Dec":null,"29-Dec":null,"30-Dec":null,"31-Dec":null}]
this is the network response but now under datatable i still get the error
Honestly, the problem we are having is that we can't debug it, and we only have partial information. Please link to a test case showing the issue so we can help.
Allan
I haven't used JSONP but as I mentioned earlier I think the problem is your server script is not supporting JSONP. Based on all the JSON responses you've posted it doesn't look like they are JSONP responses. Use the browser's network inspector with this example. and you will see the request and response are wrapping the data in a function like this
jQuery37007004015063149109_1702421439731({ ... })
.This example sends the request with
dataType: 'jsonp'
but the response is a standard JSON response with the `Invalid JSON response error as the result:https://live.datatables.net/dodobuge/52/edit
Use the browser's network inspector and you will see the request has a query string similar to this:
It expects the response to contain the function, like this:
But the response is a standard JSON response, like yours, and causes the Invalid JSON response error.
This is the same example with
dataType: 'jsonp'
commented out and it works.https://live.datatables.net/bedufoso/1/edit
Based on this it is my opinion that you either need to enable JSONP in your server script or remove
dataType: 'jsonp'
from theajax
option.As Allan said for us to help further please post a link to your page or a test case replicating the error so we can help debug.
Kevin