I believe you are right. Cancelling the earlier autocomplete search sounds like the right solution. However, I don't know exactly how to achieve that.
I've created a fiddle based on the remote datasource sample code from
http://jqueryui.com/demos/autocomplete/#remote-jsonphttp://jsfiddle.net/P7VJf/2/The desired behavior is to ensure the autocomplete does not provide suggestions if the form is submitted. Simply closing the autocomplete doesn't seem to work because it may not be open yet if the source function is still requesting the data.
I've tried using autocomplete("option","disabled",true). This prevents it from showing, but then I never really know when it's safe to enable it again (e.g. - if the remote datasource is still fetching, I wouldn't want to re-enable the autocomplete).
I've tried saving the $.ajax return and calling abort(), but that doesn't seem to work either. The only workaround I've been able to find is to wrap the autocomplete("close") call in a setTimeout so that it waits a bit before trying to close. That doesn't seem like a great solution though.
Does the autocomplete plugin have any internal methods that can be called to prevent the suggestions from showing? Maybe the _response method should check this.closing similar to the way it looks at this.options.disabled?
Any help is very much appreciated.