>我有表格来搜索数据库中的任何人。然后我想在数据表中显示搜索结果。
我正在使用刀片来模板 HTML。
这是我的表格:
<form id="myform" method="GET" action="{{ site_url('person/search') }}">
这是我的 HTML 中的数据表部分
<section class="panel" style="margin-top:20px;">
@include(config_item('theme').'.person.part.table-person', compact('result'), ['id' => 'persons'])
</section>
这是我的表:
<table id="{{ $id }}" data-toggle="table" data-mobile-responsive="true">
<thead>
<tr>
<th data-field="image" data-align="center">Image</th>
<th data-field="id" data-visible="false">ID</th>
</tr>
</thead>
</table>
最后一个是我的 AJAX 代码:
$(document).ready(function() {
$('#myform').submit(function() {
$.ajax({
dataType: json,
data: $(this).serialize(),
type: $(this).attr('method'),
url: $(this).attr('action'),
success: function(response) {
$('#persons').html(response);
}
});
return false;
});
});
有了所有这些代码,我无法显示搜索结果。
我做错了什么吗?谢谢
确保..你不能重复相同的ID名称使用 jQ 追加显示表详细信息
$('#channels').append(' <tr>
<th data-field="image" data-align="center">Image</th>
<th data-field="id" data-visible="false">ID</th>
</tr>');
提示 : http://api.jquery.com/append/