显示由'返回的数据;php';在DIV';表';

显示由'返回的数据;php';在DIV';表';,php,javascript,jquery,html,getjson,Php,Javascript,Jquery,Html,Getjson,我需要在DIV“table”中显示“getData.php”返回的数据。我该怎么做?问题是我无法访问DIV“table”中的“data”元素 PS我正在使用jquery数据表。因此,$.get('modules/drawTable.php',函数(data){…})不能正常工作(样式丢失) 模具() 我不确定我是否正确理解了这个问题,但是您是否尝试过使用.after和.append函数来填充表中的数据 顺便说一句-如果您不确定服务器响应是什么,请使用console.log(数据)-这是很棒的调试

我需要在DIV“table”中显示“getData.php”返回的数据。我该怎么做?问题是我无法访问DIV“table”中的“data”元素

PS我正在使用jquery数据表。因此,$.get('modules/drawTable.php',函数(data){…})不能正常工作(样式丢失)


模具()

我不确定我是否正确理解了这个问题,但是您是否尝试过使用.after和.append函数来填充表中的数据


顺便说一句-如果您不确定服务器响应是什么,请使用
console.log(数据)-这是很棒的调试-至少在Firefox和Chrome中是这样。

你是说
$('#table table').html(数据)相反?您是否检查了json数据输出@库萨尔:当然。getData返回json数据。能否显示json输出@请看更新的帖子。Var_dump在Firebug中打印数组。因此,数组不是空的。console.log(list)打印出数组的内容。所以数组不是空的。如何使用.after和.append?
$(document).ready(function() {
  loadData();
});

function loadData() {
   $.getJSON(
        'modules/getData.php',
        function(data) {    
               var list = list.flights;                   
               $('#table').html(list); // Also I tried this: $('#table table').html(list)
        }
       );             
    }

<div id="table" style="display:none;">
     <table>
        // display rows from 'data' array
        //<?php foreach ($data as $row):
        //  $var1=$row['var1'];....
     </table>
</div>
$list = array();
// fill the array
echo json_encode(array('flights' => $list));
var_dump($list);