Hello team我在搜索按钮输入后无法显示数据,没有显示错误 这是我的控制器
public function search(Request $request)
{
if ($request->ajax()) {
$output = "";
$products = DB::table('particulars')->where('item_name', 'LIKE', '%' . $request->search . "%")->get();
if ($products) {
foreach ($products as $key => $product) {
$output .= '<tr>' .
'<td>' . $product->id . '</td>' .
'<td>' . $product->item_name . '</td>' .
'<td>' . $product->quantity . '</td>' .
'<td>' . $product->price . '</td>' .
'</tr>';
}
return Response($output);
}
}
}
我的观点
<td>
<div class="row">
<div class="col-lg-12" style="">
<div class="input-group">
<div class="input-group-addon">
<span class="glyphicon glyphicon-search"></span>
</div>
<input type="text" class="form-control" id="search" name="search" placeholder="Search here...">
</div>
</div>
</div>
</td>
这是脚本
<script type="text/javascript">
$('#search').on('keyup',function(){
$value=$(this).val();
$.ajax({
type : 'get',
url : '/search',
data:{'search':$value},
success:function(data){
$('tbody').html(data);
}
});
})
</script>
但是我无法检索数据并且没有显示错误请团队帮助我