Create Laravel Live Search Using Ajax

Today, We want to share with you Create Laravel Live Search Using Ajax.In this post we will show you Create Live Search Box In Laravel 5.8, hear for Ajax Live Search Table Generation in Laravel we will give you demo and example for implement.In this post, we will learn about Build a live search feature with Laravel and Vue.js with an example.

Create Laravel Live Search Using Ajax

There are the Following The simple About Create Laravel Live Search Using Ajax Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel 5.8 Advance Live Search Box, so the laravel ajax get data from database for this example is following below.

Step-1 Create the Laravel Controller

php artisan make:controller LiveSearch

Step-2 LiveSearch.php

Also Read This 👉   Laravel AJAX Tutorial and MySQL Example

Simple Go to app\Controller\LiveSearch.php

namespace App\Http\Controllers;
use Illuminate\Http\Request; 
use DB;
class LiveSearch extends Controller
function index()
	return view('search_instant_live'); 
function action(Request $request) 
		$output = ''; 
		$query = $request->get('query'); 
		if($query != '') 
			$data = DB::table('tbl_member')->where('MemberName', 'like', '%'.$query.'%')
			->orWhere('Address', 'like', '%'.$query.'%')
			->orWhere('City', 'like', '%'.$query.'%')
			->orWhere('PostalCode', 'like', '%'.$query.'%')
			->orWhere('Country', 'like', '%'.$query.'%')
			->orderBy('MemberID', 'desc') ->get(); 
		$data = DB::table('tbl_member')->orderBy('MemberID', 'desc')
		$total_row = $data->count(); 
		if($total_row > 0) 
			foreach($data as $row) 
				$output .= ''.$row->MemberName.''.$row->Address.''.$row->City.''.$row->PostalCode.''.$row->Country.''; 
			$output = 'No Data Found';
		$data = array( 'table_data' => $output, 'total_data' => $total_row ); 
		echo json_encode($data); 

Step-3 LiveSearch.blade.php

Create a View File (LiveSearch.blade.php)

<!DOCTYPE html>
  <title>Live search in laravel using AJAX -</title>
  <script src=""></script>
  <link rel="stylesheet" href="" />
  <script src=""></script>
  <br />
  <div class="container box">
   <h3 align="center">Live search in laravel using AJAX</h3><br />
   <div class="panel panel-default">
    <div class="panel-heading">Search Member Data</div>
    <div class="panel-body">
     <div class="form-group">
      <input type="text" name="search" id="search" class="form-control" placeholder="Search Member Data" />
     <div class="table-responsive">
      <h3 align="center">Total Data : <span id="total_records"></span></h3>
      <table class="table table-striped table-bordered">
         <th>Member Name</th>
         <th>Postal Code</th>




 function fetch_member_data(query = '')
   url:"{{ route('search_instant_live.action') }}",

 $(document).on('keyup', '#search', function(){
  var query = $(this).val();

Step- 4 Create View And define Controller

Also Read This 👉   How to convert base64 to image and save in folder php?

Laravel Set the Routes For display or View as well as Controller

Route::get('/search_instant_live', '[email protected]'); Route::get('/search_instant_live/action', '[email protected]')->name('search_instant_live.action');

Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Create Laravel Live Search Using Ajax.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.