The post was updated and the newer version can be found here https://itswadesh.wordpress.com/2011/12/23/lets-see-how-facebook-search-is-so-fast/
I’m Swadesh, a young software engineer who is always fascinated about facebook applications.
Once i came across facebook search bar which search for friends, communities, applications, etc.
I was always wondering how the search is so quick (The result comes instantly). After a long period of research and study, i was finally able to simulate the amazing feature.
Here is the trick that worked for me
Step-1: Include Jquery and some css into your page
<script src="js/jquery.min.js"> <link href="search_style.css" rel="stylesheet" type="text/css"/>
- on page load, “Load all data of friends from database into DOM”
- Declare an array which will hold the DOM data
- Handle the keyup event which will subsequently search for the javascipt array object. If not found it will call the ajax function which will collect data from database.
- Push the retrieved data again into the DOM and search from there
Step-3: The div tag to hold the loaded result & the place to display the result
<input type="text" id="ipi"></input> <div id="search_result" style="display:none;"> </div> <div id="sr"></div>