3 years ago

Laravel live search

Posted 3 years ago by manojvarma

Hi i want to include a live search in a text field. i used ajax for that. I dont have any error but it is not showing any search results. My form is :

<form action="stationary-add-item" method="POST">
  <div class="form-group">
    <input type="text" name="searchname" class="form-control" id="searchname" placeholder="Enter item name">

My controller is :

public function autocomplete(Request $request)
        $data = stationary::where('item','LIKE','%'.$term.'%')
        foreach ($data as $key => $v){
$result[]=['value' =>$v->item];
        return response()->json($results);

route :

Route::get("/autocomplete",array('as'=>'autocomplete','uses'=> '[email protected]'));

Please sign in or create an account to participate in this conversation.