AJAX autocompletion - Should I fetch data from database for every keystroke?

Discussion in 'JavaScript' started by ready2work, Sep 17, 2008.

  1. #1
    I am trying to use ajax autocompletion for a textbox. Should I fetch data from the database for every keystroke? If I do so, it is getting delayed. What is the technique to make it fast loading?
     
    If someone posts a solution, use the "Best Answer" link in their post to pick it as the best answer.
    ready2work, Sep 17, 2008 IP
  2. ready2work

    ready2work Guest

    Best Answers:
    0
    #2
    No one here working on AJAX? :(
     
    ready2work, Sep 22, 2008 Set Best Answer IP
  3. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    On first keystroke pull in all matching values with one call to database then you javascript to pare down the array returned via ajax, if this array is to large (test number of members) Then make a second call to database with next keystroke.
     
  4. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Better yet, test record count server side, while it is to large, do not respond and let client side script keep sending requests until count is below a threshold then send response. of course all this depends on indexes for speed.