Speed Up An Ajax "Search As You Type" Function

Speed Up An Ajax "Search As You Type" Function

Hi everyone.

I'm working on a 'live search' for some products in my database. I use a web
method in an aspx page to hit the database up for data. The search fires off on
each keyup event. Here's the code that is fired to get the search results:

  1. jQuery.ajax({
     contentType : 'application/json; charset=utf-8',
     data        : '{"searchString":"' + jQuery('#searchText').val() + '"}',
     dataType    : 'json',
     error       : function (response) { getSearchResultsFail(response); },
     success     : function (response) { getSearchResultsSuccess(response); },
     type        : 'POST',
     url         : 'Default.aspx/GetSearchResults'
    });








  2. function getSearchResultsSuccess(response)
    {
     parse json object & create dynamic list items here...
    }



 
 
My problem is that when a user types in the input field really fast, the whole
page slows down, it looks like the user isn't typing and there is a lot of lag
for the cursor to catch up with the current position. What can I do to prevent
this slowdown in my input field and speed up my page responding to the user's
typing? I'd really like to have fast results and response time like Google's
search.