Reputation: 230
I'm trying to pass some data to DataTables as an array, initialized to a variable that I have tried to initialize as an array. I have also tried wrapping the array up as JSON per the examples on Datatables website, adding an encircling pair of braces, and setting "data" to equal the array. That JSON validates correctly with JSONLint. However, in all of these cases, Datatables gives me the dreaded:
"DataTables warning: Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1"
Here, and in the JSFiddle, is a minimal example:
var dataIn = [
["ma\u02d0hu ha\u02d0\u00f0a", "What?", "Final 'what' interrogative in each Yemen series is object, subject interrogatives are marked for gender", "Y24", "closed-class,interr.what,masculine,subject", "Behnstedt85YemenAtlas: m. 60", "red"],
["ma\u02d0hu\u02d0\u00f0e\u0294", "What?", "Final 'what' interrogative in each Yemen series is object, subject interrogatives are marked for gender", "Y156", "closed-class,interr.what,masculine", "Behnstedt85YemenAtlas: m. 60", "red"]
];
$(document).ready(function(){
$("#results").dataTable({
"ajax" : dataIn
});
});
https://jsfiddle.net/ype8zag5/2/
Upvotes: 0
Views: 81
Reputation: 1715
https://jsfiddle.net/ype8zag5/5/
You were trying to send an ajax request to the table itself.
If you have the data already in a var then you assign it with data:
var dataIn = [
[
"maːhu haːða",
"What?",
"Final 'what' interrogative in each Yemen series is object, subject interrogatives are marked for gender",
"Y24",
"closed-class,interr.what,masculine,subject",
"Behnstedt85YemenAtlas: m. 60",
"red"],
[
"maːhuːðeʔ",
"What?",
"Final 'what' interrogative in each Yemen series is object, subject interrogatives are marked for gender",
"Y156",
"closed-class,interr.what,masculine",
"Behnstedt85YemenAtlas: m. 60",
"red"]
];
$(document).ready(function () {
$("#results").dataTable({
data: dataIn // Changed
});
});
Upvotes: 1