Link to home
Start Free TrialLog in
Avatar of jfergy
jfergy

asked on

Jquery UI AutoComplete On Key Up

hello-

I am using JqueryUI Auto Complete which works fine for simple things, however I need it to return values on every keystroke after the minimum entered. Right now, JqueryUI only returns the data from the first" minLength" entered. So what I need it do is:

Continue to hit my server with every key stroke after the minimum so the user continues to see the list change as they input text. Any help is appreciated.
<script>
	$(function() {
		var cache = {},
			lastXhr;
		$( "#addresses" ).autocomplete({
			minLength: 4,
			source: function( request, response ) {
				var term = request.term;
				if ( term in cache ) {
					response( cache[ term ] );
					return;
				}

				lastXhr = $.getJSON( "addresses.asp", request, function( data, status, xhr ) {
					cache[ term ] = data;
					if ( xhr === lastXhr ) {
						response( data );
					}
				});
			}
		});
	});

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Vampireofdarkness
Vampireofdarkness
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jfergy
jfergy

ASKER

I understand whats happening now, what I need is the ability for it to continue to send what someone types in after the minlength. Right now it sends the Term to the json page as the min length but does not continue as someone types.