I cannot search using ajax.. that is my problem i need to search w/o refreshing . thanks hope someone can help me.
My Controller
Here is my controller code, please take a look am i missing something here?
public function search(Request $request){
if($request->ajax())
{
$employees = DB::table('employeefms')->where('last_name','LIKE','%'.$request->search.'%')
->orWhere('first_name','LIKE','%'.$request->search.'%')->get();
return response();
}
}
my View
here is my view please take a look i know i have a lot of fields in here lol. please check if ever im missing somthing in the ajax code hrer
@foreach ($employees as $employee)
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><a href="/admin/employeemaintenance//edit" class="btn btn-primary btn-sm"><i class="fa fa-edit"></i></a></td>
<td>
{!!Form::open(['action'=>['Admin\EmployeeFilemController@destroy', $employee->id],'method'=>'POST', 'align'=>'right'])!!}
{!!Form::close()!!}
</td>
</tr>
</tbody>
@endforeach
my AJAX
<script type="text/javascript">
$('#search').on('keyup',function(){
$value=$(this).val();
$.ajax({
type : 'get',
url : '',
data : {'search':$value},
success:function(data){
var data1 = jQuery.parseJSON(data);
if(data1.msg == "success"){
$.each(eval(data1.data), function(){
$('tbody').html(data);
})
},
//no data found
}
});
})
</script>
Here is my ajax code
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2G1VG1r
via IFTTT
Aucun commentaire:
Enregistrer un commentaire