Make Autocomplete Search with jQuery AJAX



Autocomplete search filter display suggestion based on the user input e.g. listing all products which start with character ‘a’.
It makes easier for the user to search for an item from the list and select it from the suggestion list.
Require jQuery AJAX for implementing this.
Whenever the user enters a character send an AJAX request to fetch records with PHP and display the result.
In the demonstration, I show a textbox to search users. When an item selected from the suggestion list then fetch details of the selected users and display on the screen.

Contents

  1. Table structure
  2. Configuration
  3. HTML
  4. CSS
  5. PHP
  6. jQuery
  7. Demo
  8. Conclusion

1. Table structure

I am using user table in the example.
CREATE TABLE `user` (
  `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
  `username` varchar(100) NOT NULL,
  `name` varchar(100) NOT NULL,
  `email` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;