2

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 Answers2

0

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/

0

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

Yaron U.
  • 7,681
  • 3
  • 31
  • 45
  • Thanks Yaron for your answer. its useful. But my exact requirement is, as soon as the page loads it should push the friends information to cache. so that users won't have to wait while searching for friends. As well as when they search the same string again they should not wait for the query to process through the server. – itswadesh.wordpress.com Jan 22 '12 at 15:38
  • I understood what was your meaning, but this is a bad way of implementing it. for large db this will be a huge waste. the plugins also cache recent search so that they wont need to refetch the data from the search. (and the first pull of the data doesn't suppose to take much time if you design your db correctly) - it worth the half second, you can always add preloader – Yaron U. Jan 22 '12 at 17:03