php - 无法使用 Ajax 将数据搜索到数据表中 - Codeigniter
问题描述
大家好,我正在创建一个门户网站。我想添加显示数据表。我为此使用 Datatable 插件,但我遇到了一些问题。请帮我解决一下这个。
这是我的控制器代码
public function fetchTeams() {
$data = $this->Teams_model->getAllTeams();
echo json_encode(array("data" => $data));
}
我的 HTML 视图
<div class="card-body">
<table id="teamDatatable" class="display table table-bordered table-hover" width="100%">
<thead>
<tr>
<th>Employee name</th>
<th>Email</th>
<th>Gender</th>
<th>Salary</th>
<th>City</th>
</tr>
</thead>
</table>
</div>
我的模特
public function getAllTeams() {
$query = $this->db->get("teams");
return $query->result_array();
$query1 = $this->db->get('Teams');
$data1 = $query->num_rows();
$response = array(
"iTotalRecords" => $data1,
"aaData" => $data
);
return $response;
}
解决方案
希望这会有所帮助 在此处检查我的服务器端 codeigniter 脚本 服务器端数据表 codeigniter
推荐阅读
- javascript - 如何从 axios 响应的数组中显示对象的单个属性(多次)?
- mysql - mysql内部连接表上的左连接
- sql - 按键/值过滤 JSON 数组元素的 PostgreSQL (v9.6) 查询
- python - 数字字符串转换为 int 并添加到列表中(优化问题)
- python - 如何在最后两个反斜杠之间查找和添加子字符串?
- python - 如何使用比较运算符过滤还包含字符串作为值的字典中的整数?
- javascript - HTML & Javascript - 仅显示特定对象的按钮
- c - 在函数中修改和返回结构
- excel - 在 EXCEL/GOOGLE SHEETS 中计算具有多个条件和范围的多个值
- ssl - 在 EC2 上的生产中的 Phoenix 未使用 AWS 负载均衡器在 HTTPS 中呈现