如何在不配置e table forrver端处理的情况下从php填充jquery数据表

时间:2017-01-25 00:28:45

标签: javascript php jquery datatables

我想在我的$(document).ready函数中填充来自php调用的数据表,但是我不想为服务器端处理配置表(我希望后续的排序/过滤/排序发生客户端)。以下是我目前的代码。注意:我在服务器上运行php并将输出粘贴到文本文件中。如果我使用文本文件的路径作为我的网址,我会得到预期的结果。所以我认为datatables试图将我的php文件读作json,当然也失败了。如何让它使用php文件的输出而不是php文件本身?

代码:

<html>
    <head>
        <title>NCompass Failed Fax Monitor</title>

        <link rel="stylesheet" type="text/css" href="jQuery/datatables.min.css"></link>

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
        <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
        <script>
            $(document).ready(function() {
                $('#faxList').DataTable({
                    ajax: {
                        url: 'php/Data.php',
                        dataSrc: 'transactions'
                    },
                    columns: [
                        { data: 'PROCESS_DATE' },
                        { data: 'PROCESS_STATUS' },
                        { data: 'PDF_FILE_NAME' },
                        { data: 'REF_ID' },
                        { data: 'ADDITIONAL_INFO' }
                    ]
                });
            });
        </script>
    </head>
    <body>

        <h2>NCompass Failed Fax Monitor</h2>
        <br>

        <table width="100%" class="display" cellspacing="0" id="faxList">
            <thead>
                <tr>
                    <th>Process Date</th>
                    <th>Status</th>
                    <th>PDF File</th>
                    <th>Reference ID</th>
                    <th>Error Description</th>
                </tr>
            </thead>
        </table>
    </body>
</html>

0 个答案:

没有答案