在這里我是新手ajax DataTables。我正在嘗試connect我的database和. 但我得到了這個錯誤:fetch recordsdataTabledatatables warning table id=datatables-example - invalid json response有關此錯誤的更多信息,請參閱 http://datatables.net/tn/1我遵循了名為 的教程web lesson,以防我試圖在互聯網上找到解決方案但沒有幫助我解決我的問題。這是我的HTML片段: <table id="datatables-example" class="table table-striped table-bordered" width="100%" cellspacing="0"> <thead> <tr> <th>Appointment ID</th> <th>Doctor Name</th> <th>Specialization</th> <th>Patient Name</th> <th>Fees</th> <th>Appointment Date</th> <th>Appointment Time</th> <th>Status</th> <th class="text-right">Action</th> </tr> </thead> </table>以下是Ajax片段:<script>$(document).ready(function() {load_data();function load_data(){ var datatable= $('#datatables-example').DataTable({ "processing": true, "serverSide": true, "order" :[], "ajax" : { url: "sidebar/apt_table admin.php", // Url to which the request is send method: "POST", // Type of request to be send, called as method } });}});</script>
2 回答

開滿天機
TA貢獻1786條經驗 獲得超13個贊
要實現服務器端 ajax 數據表,您的腳本應該返回 json 只有您發送帶有一些<tr>
和<td>
參考:https ://datatables.net/examples/data_sources/server_side
在上面的示例源中,僅提供 json 輸出。
所以,試著修復你的apt_table admin.php

慕尼黑的夜晚無繁華
TA貢獻1864條經驗 獲得超6個贊
試試這個小調試(在“post”末尾檢索逗號)
"ajax" : { url: "sidebar/apt_table admin.php", method: "POST" }
- 2 回答
- 0 關注
- 131 瀏覽
添加回答
舉報
0/150
提交
取消