Simulating facebook search using jquery

1.9k Views Asked by At

I'm Swadesh, a young software engineer who is always fascinated about facebook applications.

Once I came across facebook search bar which searches for friends, communities, applications, etc.

I just love it, because its so fast and gives you intelligent and instant result.

I tried a similar one using JQuery. The project with a demo can be found here

Now the issue I’m facing is: I get duplicate records inserted into DOM(from where I search for the string).

The javascript search idea is as follows

  • On page load, “Load all data of friends from database into DOM”
  • Declare an array which will hold the DOM data
  • Push the DOM data into the javascript array
  • 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
2

There are 2 best solutions below

0
On BEST ANSWER

Solved. During this last 6 months duration i went through different kind of solutions and finally found out the result. An exact search feature with demo and download link i posted here. http://itswadesh.wordpress.com/2011/12/23/lets-see-how-facebook-search-is-so-fast/

2
On

in order to handle a lot of data you should not load all the possible data to the dom while loading the page. use ajax to load the desired results and cache them in your code in order to prevent multiple calls for the same phrase. (this is also what facebook does on their search)

there are many jquery plugins out there that will make it extremely easy to integrate in your site

for example, this one: http://docs.jquery.com/Plugins/Autocomplete