Jquery autocomplete remote call - disable after a space

Jquery autocomplete remote call - disable after a space

Sometimes my autocomplete ajax takes too long and the response happens too late - is there anyway to close the autocomplete processing/drop down (ignore the results from the JSON) once a user enters a space character?

Thanks

I'm using:
  
  1. 	$(function() {
    		var cache = {},
    			lastXhr;
    		$( "#birds" ).autocomplete({
    			minLength: 2,
    			source: function( request, response ) {
    				var term = request.term;
    				if ( term in cache ) {
    					response( cache[ term ] );
    					return;
    				}
    
    				lastXhr = $.getJSON( "search.php", request, function( data, status, xhr ) {
    					cache[ term ] = data;
    					if ( xhr === lastXhr ) {
    						response( data );
    					}
    				});
    			}
    		});
    	});