Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

CloudWays Blog:
Create Live Search In Laravel Using AJAX
Dec 07, 2017 @ 18:55:08

The Cloudways blog has posted a new tutorial for the Laravel users out there showing you how to create a "live search" box for the contents of your site. They use an e-commerce example and make use of some simple Javascript to return results from a backend script.

Whether you have a blog or an ecommerce store, a search bar is always an essential component of the UI. However, the days of simple search bar is over. These days, a live search bar is much more efficient than a simple search bar because it displays similar content in real time. This increases the chance of landing a sale because the customer could see the largest selection of related products.

The article starts off with the prerequisites for following along including an installation of PHP, MySQL, Apache and Laravel. They include an optional step of setting it all up on a Cloudways server but this isn't required if you want to do it locally. The tutorial then walks through the setup steps and creating the migration for the "products" table it will search. It also shows the creation of the controller and routes for the search endpoints and the view with the Javascript to make the Ajax request. It finishes with a way to test the result and a screenshot of what should be returned.

tagged: live search laravel tutorial ajax request ecommerce

Link: https://www.cloudways.com/blog/live-search-laravel-ajax/


Trending Topics: