AJAX Live Search is a PHP search form that similar to Google Autocomplete feature displays the result as you type.
Check it live (will be updated soon).
IE 8+ ✔ | Chrome ✔ | Firefox ✔ | Opera ✔ | Safari ✔ |
-
Copy the folders including
ajax
,core
,css
,font
,img
andjs
folders to your project. -
Open
index.php
and copydiv
with the class namels_container
somewhere in your page. Also do not forget to include links to CSS and JavaScript files includingstyle.min.css
,fontello.css
,animation.css
,fontello-ie7.css
,script.min.js
andjquery-1.11.1.min.js
. Also do not forget to copy all the PHP codes from the top ofindex.php
to your project. -
Config.php
that is located incore
folder contains all the settings for AJAX Live Search:host
: Hostname of your database that is usuallylocalhost
.database
: Name of your database.username
: The user associated with your database.pass
: Password for the user.table
: Name of the table that you want to be searched.searchColumn
: Name of the column that you want to be searched.antiBot
: This is used in a security technique to prevent form submissions from those bots that do not use JavaScript. In this technique, a hidden field is populated using jQuery with this value. You can set it whatever you want, but it MUST be the same asform_anti_bot
value inscript.min.js
file.searchStartTimeOffset
: This is for another security technique against bots. Some bots immediately submit a form once the page is finished loading. However, for human beings it takes more time to fill a field. By default this parameter is set to 3 seconds.maxInputLength
: This specifies the maximum length of characters in search field.filterResult
: Can contain column names and is used to filter result. If it is an empty array everything will be returned.
-
script.min.js
orscript.js
that is located in js folder contains all the JavaScript (jQuery) settings and functions for AJAX Live Search. Here you should only be worried aboutform_anti_bot
value and as you know it MUST be the same asantiBot
value inConfig.php
. You also need to setselect_column_index
which specifies the index of td element in result rows. This is used when user selects a row and the specified td element is copied into search field. -
process_livesearch.php
that is located in ajax folder is responsible for processing requests coming from the search form. Here you just need to setAccess-Control-Allow-Origin header
.