【发布时间】:2016-06-14 18:41:32
【问题描述】:
我有表格可以搜索数据库中的任何人。 然后我想在DataTable中显示搜索结果。
我正在使用 Blade 模板化 HTML。
这是我的表格:
<form id="myform" method="GET" action="{{ site_url('person/search') }}">
这是我的 HTML 中的 DataTable 部分
<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;
});
});
使用所有这些代码,我无法显示搜索结果。
我做错了吗? 谢谢
【问题讨论】:
-
response的返回数据是什么?
-
dataType: 'JSON'在引号之间
标签: php jquery ajax datatable blade