observe_form misbehaving - requests processed out of order?

scenario:
I used the observe_form to build a live search. It worked perfect until
I loaded a large amount of data and tested it in a production
environment.

symptoms:
when I am searching for 'john' I type in 'j', 'o', 'h', and then finally
'n'. The observe field goes through and sends me the correct values but
then searches for only 'j' at the end.

possible reason:
I think it is because the 'j' request takes up more time then the full
'john' and it still process that request, but it unfortunately processes
them out of order.

possible solution:
create a hidden field that increments the requests. If I get a request
back that is less than the current one I know not to process it.

Any other ideas?

Any hints on how I would implement this? I've got my javascript
increment function and check function, but I'm not quite sure how to
work this out with the observe_field. when would i fire these
javascript functions off?

thanks

Set a frequency of around 500 on the observe_field. It’s calling the function on the letter j because that’s the first event that the field changes on.

Ryan Bigg wrote:

Set a frequency of around 500 on the observe_field. It's calling the
function on the letter j because that's the first event that the field
changes on.

That would defeat the purpose of a live search. A live search responds
to what is typed in the field. The observe field must be listening at a
much smaller frequency than that. Example here:
http://www.recentrambles.com/pragmatic/view/59

I should call the function with the letter j because, yes, it is the
first event. the problem is that it takes longer and than the last
request.

Here's the important bits from one I have setup:

Live Search: <%= text_field 'search', 'term', :size => 12 %>

<div id="wait" style="display:none;">Wait!</div>

<%= observe_field 'search_term', :frequency => 1.0,
                                  :update => 'target_id',
                                  :url => { :controller => 'search',
                                                    :action => 'search' },
                                  :with => "'search=' + escape(value)",
                                  :loading => "Element.show( 'wait' );",
                                  :complete => "Element.hide( 'wait' );" %>

Again, I'm not sure if we are understanding the problem. I believe I am
using the observe field correctly, but it appears that the requests are
getting out of order.

Has anyone seen this behavior?