我没有使用Jquery获取数据

时间:2014-02-15 20:20:28

标签: php jquery mysql jqxgrid

我使用下面的代码从数据库中获取数据。这里没问题.....

$query = "SELECT * FROM takenlijst";
$from = 0; 
$to = 999;
$query .= " LIMIT ".$from.",".$to;
$result = mysql_query($query) or die("SQL Error 1: " . mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$taken[] = array(
'taaknummer' => $row['taaknummer'],
'naam' => $row['naam'],
'taak' => $row['taak'],
'prioriteit' => $row['prioriteit'],
'datum' => $row['datum']
  );
}
echo json_encode($taken);

然而,当我使用下面的代码时,我得不到任何数据。我做错了什么?

<html lang="en">
<head>
<link rel="stylesheet" href="../../jquery/jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="../../jquery/scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../../jquery/jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jquery/jqwidgets/jqxdata.js"></script> 
<script type="text/javascript" src="../../jquery/jqwidgets/jqxbuttons.js"></script>
<script type="text/javascript" src="../../jquery/jqwidgets/jqxscrollbar.js"></script>
<script type="text/javascript" src="../../jquery/jqwidgets/jqxmenu.js"></script>
<script type="text/javascript" src="../../jquery/jqwidgets/jqxgrid.js"></script>
<script type="text/javascript" src="../../jquery/jqwidgets/jqxlistbox.js"></script>
<script type="text/javascript" src="../../jquery/jqwidgets/jqxdropdownlist.js"></script>
<script type="text/javascript" src="../../jquery/jqwidgets/jqxgrid.sort.js"></script>
<script type="text/javascript" src="../../jquery/jqwidgets/jqxgrid.filter.js"></script>
<script type="text/javascript" src="../../jquery/jqwidgets/jqxgrid.selection.js"></script> 
<script type="text/javascript" src="../../jquery/jqwidgets/jqxgrid.columnsresize.js"></script> 
<script type="text/javascript" src="../../jquery/scripts/demos.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        // prepare the data
        var source =
        {
            datatype: "json",
            datafields: [
            { name: 'taaknummer', type: 'string'},
            { name: 'naam', type: 'string'},
            { name: 'taak', type: 'string'},
            { name: 'prioriteit', type: 'string'},
            { name: 'datum', type: 'string'}
            ],
            url: 'http://www.site.com/management/takenlijstdata.php',
            cache: false
        };

        var dataAdapter = new $.jqx.dataAdapter(source);

        $("#jqxgrid").jqxGrid(
        {
            source: dataAdapter,
            columns: [
            { text: 'Taaknummer', datafield: 'taaknummer', width: 250},
            { text: 'Naam', datafield: 'naam', width: 150 },
            { text: 'Taak', datafield: 'taak', width: 180 },
            { text: 'Prioriteit', datafield: 'prioriteit', width: 200 },
            { text: 'Datum', datafield: 'datum', width: 120 }
            ]
        });
    });
 </script>
</head>
<body class='default'>
 <div id="jqxgrid"></div>
</body>
</html>

echo正确显示数据。即使我将数据输出到txt文件,也可以读取,但是当我尝试从这段代码中读取数据时,它就不会被读取。

0 个答案:

没有答案