数据表不接受有效数组作为源(即 "ajax" = )

Datatables won't accept valid array as source (i.e "ajax" = )

我正在尝试将一些数据作为数组传递给 DataTables,并初始化为我尝试初始化为数组的变量。我还尝试根据 Datatables 网站上的示例将数组包装为 JSON,添加一对环绕的大括号,并将 "data" 设置为等于数组。 JSON 使用 JSONLint 正确验证。然而,在所有这些情况下,Datatables 让我感到害怕:

"DataTables warning: Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1"

这里和 JSFiddle 中有一个最小的例子:

    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/

https://jsfiddle.net/ype8zag5/5/

您正试图向 table 本身发送 ajax 请求。

如果您的数据已经存在于 var 中,那么您可以为其分配数据:

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
    });
});