Laravel 10 JQuery UI Ajax Autocomplete Search Example

By Hardik Savani November 6, 2023 Category : Laravel

Hey Guys,

This example is focused on laravel 10 autocomplete search using jquery ui. you can see laravel 10 jquery ui autocomplete search. you can understand a concept of laravel 10 autocomplete input box using jquery ui. I explained simply about laravel 10 autocomplete textbox box using jquery ui. Here, Create a basic example of laravel 10 jquery ui ajax autocomplete example.

In this example, we will download the fresh laravel 10 app and run migration for creating users table. Then we will create some dummy users using Tinker. Then we will create a simple blade file with the input field. we will create an autocomplete text box using jquery ui js.

Step for Laravel 10 Ajax Autocomplete Search using JQuery UI Example

  • Step 1: Install Laravel 10
  • Step 2: Add Dummy Users
  • Step 3: Create Controller
  • Step 4: Create Routes
  • Step 5: Create View File
  • Run Laravel App

So, let's see the simple steps to complete this task.

Step 1: Install Laravel 10

This is optional; however, if you have not created the laravel app, then you may go ahead and execute the below command:

composer create-project laravel/laravel example-app

Step 2: Add Dummy Users

First, we need to run default migrations, so we have created new users table. so let's run migration command:

php artisan migrate

next, we will create some dummy users using tinker factory. so let's create dummy records using bellow command:

php artisan tinker


Step 3: Create Controller

In this point, now we should create new controller as SearchController. This controller we will add two method, one for return view response and another for getting ajax with json response. return response, so put bellow content in controller file:



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Models\User;

use Illuminate\View\View;

use Illuminate\Http\JsonResponse;

class SearchController extends Controller



* Display a listing of the resource.


* @return \Illuminate\Http\Response


public function index(): View


return view('searchDemo');



* Show the form for creating a new resource.


* @return \Illuminate\Http\Response


public function autocomplete(Request $request): JsonResponse


$data = User::select("name as value", "id")

->where('name', 'LIKE', '%'. $request->get('search'). '%')


return response()->json($data);



Step 4: Create Routes

In this is step we need to create route for datatables layout file and another one for getting data. so open your "routes/web.php" file and add following route.



use Illuminate\Support\Facades\Route;

use App\Http\Controllers\SearchController;



| Web Routes



| Here is where you can register web routes for your application. These

| routes are loaded by the RouteServiceProvider within a group which

| contains the "web" middleware group. Now create something great!




Route::get('demo-search', 'index');

Route::get('autocomplete', 'autocomplete')->name('autocomplete');


Step 5: Create View File

In Last step, let's create searchDemo.blade.php(resources/views/searchDemo.blade.php) for layout and lists all items code here and put following code:


<!DOCTYPE html>



<title>Laravel 10 JQuery UI Autocomplete Search Example -</title>

<link href="" rel="stylesheet">

<link rel="stylesheet" href="" />

<script src=""></script>

<script src=""></script>



<div class="container">

<h1>Laravel 10 JQuery UI Autocomplete Search Example -</h1>

<input class="typeahead form-control" id="search" type="text">


<script type="text/javascript">

var path = "{{ route('autocomplete') }}";

$( "#search" ).autocomplete({

source: function( request, response ) {


url: path,

type: 'GET',

dataType: "json",

data: {

search: request.term


success: function( data ) {

response( data );




select: function (event, ui) {



return false;






Run Laravel App:

All the required steps have been done, now you have to type the given below command and hit enter to run the Laravel app:

php artisan serve

Now, Go to your web browser, type the given URL and view the app output:



I hope it can help you...