[jQuery] Stopping a $.load call

[jQuery] Stopping a $.load call


Hello everyone. This is a general question about stopping (or
overriding) an AJAX call once it has been made. In order to illustrate
my question I can give a specific example, but I'm sure this topic is
applicable to many people besides myself.
So, here's the page I'm working on right now: http://lpforest.org/documents
If you start typing in the "Search Phrase" box (or use any of the
other form elements) you'll notice the results will begin to narrow.
This is accomplished using jQuery and $.load. Every time a form
element changes it fires "documents_db_narrower_actor", which loads
dynamic_forms.php into div#documents_db_narrower_results. Simple
enough, right?
The problem is that over slow or lossy connections the search results
jump around a lot. That makes sense because after typing every letter
a new AJAX request is made. So when I type "artichoke" I actually make
9 requests to dynamic_forms.php. That's not necessarily a bad thing,
but oftentimes an earlier request shows up last (e.g. I'm looking at
the results for "artichoke", but then they're erased with the results
for "arti"). When this happens I need to delete a letter and re-type
it to get the desired results.
Hopefully everything I've said above makes sense so far. My question
is if there's a way to cancel, negate, or override a previously made
$.load call. That is, if someone types "artichok", and then 3
milliseconds later finishes the word by typing "e", is there a way to
cancel existing $.load requests before making a new one? I realize my
algorithm is very basic; should I be doing something more complex to
make things work better?
Thanks in advance for your insight.
Brian