使用jquery时没有结果

时间:2014-02-07 13:40:17

标签: php jquery mysql

我刚开始使用jquery,我正在使用jqwidgets。我假设所有的jquery文件都是正确的,所以问题必须在我自己的代码中。有两个文件,takelijstdata.php和takenlijst.php。第一个执行查询,它在数组中显示正确的一切。

当我打开takenlijst.php时,我应该给我一张带有一些过滤选项的表格,我会得到一个空页面。

<!DOCTYPE html>
<html lang="en">
<head>
    <title id='Description'>Testpagina.</title>
    <script type="text/javascript" src="http://www.site.com/jquery/scripts/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxdata.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxlistbox.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxdropdownlist.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxmenu.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxgrid.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxgrid.filter.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxgrid.sort.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxgrid.selection.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxpanel.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxcalendar.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxdatetimeinput.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/jqxcheckbox.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/jqwidgets/globalization/globalize.js"></script>
    <script type="text/javascript" src="http://www.site.com/jquery/scripts/demos.js"></script>
    <script type="text/javascript" src="generatedata.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {

        // prepare the data

        var source =
            {
                localdata: data,
                datafields:
                [
                    { name: 'taaknummer', type: 'string' },
                    { name: 'naam', type: 'string' },
                    { name: 'taak', type: 'string' },
                    { name: 'prioriteit', type: 'string'},
                    { name: 'datum', type: 'date' }
                ],
                datatype: "array",
                url: 'http://www.site.com/management/takenlijstdata.php',
                async: false
            };

        var dataAdapter = new $.jqx.dataAdapter(source);
            $("#jqxgrid").jqxGrid(
            {
                width: 685,
                source: dataAdapter,
                showfilterrow: true,
                filterable: true,
                selectionmode: 'multiplecellsextended',
                columns: [
                  { text: 'Name', columntype: 'textbox', filtertype: 'textbox', filtercondition: 'starts_with', datafield: 'taaknummer', width: 115 },
                  {
                      text: 'naam', filtertype: 'checkedlist', datafield: 'naam', width: 220
                  },
                  { text: 'taak', datafield: 'available', columntype: 'checkbox', filtertype: 'bool', width: 67 },
                  { text: 'prioriteit', datafield: 'date', filtertype: 'date', width: 210, cellsalign: 'right', cellsformat: 'd' },
                  { text: 'datum', datafield: 'quantity', filtertype: 'number',  cellsalign: 'right' }
                ]
            });
            $('#clearfilteringbutton').jqxButton({ height: 25});
            $('#clearfilteringbutton').click(function () {
                $("#jqxgrid").jqxGrid('clearfilters');
            });
        });
     </script>
</head>
<body class='default'>
    <div id="jqxgrid">
    </div>
    <input style="margin-top: 10px;" value="Remove Filter" id="clearfilteringbutton" type="button" />
</body>
</html>

同样,我是jquery的新手,所以如果这是一个奇怪/愚蠢的问题,我很抱歉。

2 个答案:

答案 0 :(得分:0)

看看这个,我看到你在实例化源变量时引用了变量“data”,但我没有看到你的页面上任何地方都定义了“data”变量。

答案 1 :(得分:0)

我在这里看到另一个问题:1。数据未定义,2。你设置“url”和“localdata”。您应该使用“url”或“localdata”。示例:jqwidgets grid