Onkeyup event slow in IE - autocomplete search attempt
I have setup a keyup event on a textbox that clears a timer every keystroke, and uses the settimeout function to execute an ajax request. Every browser works great except for IE8 and I am assuming 7. Every key that you type lags in the textbox, but ajax request functions as expected. How do I stop the lagging? I could type 3 letters and they dont show up right away. I appreciate any advice.
Below is a code example:
- //Keypress Function To Block Enter Key
- $("#textbox").keyup(function(event){
- currentFilter = $(this).val();
-
- if (event.which == 13)
- {
- event.preventDefault();
- }
-
- else
- {
-
- //Clear Timer When Needed
-
- clearTimeout(timer);
-
- timer = setTimeout(function(){
-
- searchServer(currentFilter)}, 1000);
-
- }
-
- });
- function searchServer(currentFilter)
- {
- var urlString = currentServer + provisionerController + "?" + action + "=" + actionValue + "&" + partnerGroupAction + "=" + selectedAccountGroupText + "&" + filteredTextAction + "=" + currentFilter;
- var webSafeUrl = encodeURI(urlString);
-
- $.ajax({
- url: webSafeUrl,
- dataType: "html",
- cache: false,
- type: "POST",
- beforeSend: function(){
- loadingImage.show();
- },
-
- complete: function(){
- loadingImage.hide();
- },
-
- success: function(data){
- accountsTableDataContainer.html(data);
- }
-
- });
- }