I did something like this:
jQuery(".auto_search_complete").live("click", function() {
var $this = jQuery(this);
$this.autocomplete({
minLength: 3,
source: function (request, response) {
jQuery.ajax({
url: "/autocomplete.json",
data: {
term: request.term
},
success: function (data) {
if (data.length == 0) {
// You would enter a return for printing "No Response" here.
// I did:
// $this.siblings('span.guest_email').show();
// $this.siblings('span.delete_button').show();
}
response(data);
}
});
},
// ... Rest of your stuff here, like focus, select... this above bit is your answer....
I used jQuery
because my $ was taken up with prototype so i had to differ.
So notice you have to use the long form of the ajax request, not the fancy quick one, because you want to break up the success into that 'if there is no data clause'