Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 无法使用源为Javascript的数据表显示数据_Jquery - Fatal编程技术网

Jquery 无法使用源为Javascript的数据表显示数据

Jquery 无法使用源为Javascript的数据表显示数据,jquery,Jquery,我使用jquerydatatables来显示使用Javascript作为数据源的数据 这是我的完整程序,当我运行下面的程序时,它显示一个空表。 谁能告诉我如何解决这个问题 <html> <head> <link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.0/css/jquery.dataTables.css"> <script src="htt

我使用jquerydatatables来显示使用Javascript作为数据源的数据

这是我的完整程序,当我运行下面的程序时,它显示一个空表。 谁能告诉我如何解决这个问题

<html>
<head>
       <link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.0/css/jquery.dataTables.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://cdn.datatables.net/1.10.0/js/jquery.dataTables.js"></script>
<script>

var dataddd = {

  "data": [
    {
      "first_name": "Airi",
      "last_name": "Satou",
      "position": "Accountant",
      "office": "Tokyo",
      "start_date": "28th Nov 08",
      "salary": "$162,700"
    },
    {
      "first_name": "Angelica",
      "last_name": "Ramos",
      "position": "Chief Executive Officer (CEO)",
      "office": "London",
      "start_date": "9th Oct 09",
      "salary": "$1,200,000"
    }
  ]
};


$(document).ready(function() {
    $('#example').dataTable( {
     "aaData": dataddd,
            "columns": [
            { "data": "first_name" },
            { "data": "last_name" },
            { "data": "position" },
            { "data": "office" },
            { "data": "start_date" },
            { "data": "salary" }
        ]
    } );
} );

</script>
</head>
<body>

<table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Extn.</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
    </table>

</body>
</html>

var dataddd={
“数据”:[
{
“名字”:“Airi”,
“姓氏”:“Satou”,
“职位”:“会计”,
“办公室”:“东京”,
“开始日期”:“2008年11月28日”,
“工资”:“$162700”
},
{
“名字”:“Angelica”,
“姓氏”:“拉莫斯”,
“职位”:“首席执行官(CEO)”,
“办公室”:“伦敦”,
“开始日期”:“2009年10月9日”,
“工资”:“$1200000”
}
]
};
$(文档).ready(函数(){
$('#示例')。数据表({
“aaData”:dataddd,
“栏目”:[
{“数据”:“名字”},
{“数据”:“姓氏”},
{“数据”:“位置”},
{“数据”:“办公室”},
{“数据”:“开始日期”},
{“数据”:“工资”}
]
} );
} );
名称
位置
办公室
Extn。
开始日期
薪水

您需要编写
dataddd.data
而不是
dataddd

$('#example').dataTable( {
 "aaData": dataddd.data,
        "columns": [
        { "data": "first_name" },
        { "data": "last_name" },
        { "data": "position" },
        { "data": "office" },
        { "data": "start_date" },
        { "data": "salary" }
    ]
});