A much better solution is to set a delay on the keyup, say, half a second,
then execute the ajax request when that timeout finishes. Its much easier on
your server to do it this way.

On 8/22/07, Tamm Sjödin <[EMAIL PROTECTED]> wrote:
>
> actually that made things even more confusing :P
>
> for the record, I've found a solution to my problem, it doesn't do what I
> first wanted but it works really well.
> basically I used the var xhr=$ajax; solution and added:
>
> $("#thing").keypress(function(){xhr.abort();});
>
> this aborts all previous requests on a new key input (But only the
> requests in this function, I know.)
>
> the solution is suboptimal but it's okay. it'd be great if the ajax
> function came with a killall() so when you want to stop any requests you
> could just call $.ajaxkillall();
>
> On 8/22/07, lordb <[EMAIL PROTECTED]> wrote:
> >
> >
> > You can easily prevent execution of ajax request with a flag.
> >
> > When you make an Ajax call the flag is set to 1 (if its allready to 1
> > you don't launch request)
> >
> > In the callback you just turn back the flag to 0 and you can perform a
> > quick test to for comparing the last search made width the actual
> > search parameter
> > (if different you force a new call else it's done)
> >
> > 'Hope that's help you
> >
> > On Aug 22, 8:59 am, "Tamm Sjödin" < [EMAIL PROTECTED]> wrote:
> > > It's a search function that I trigger on key up. It doesn't work bad
> > it's
> > > just a risk of previous requests finishing after the last one, meaning
> > the
> > > content of the result box being replaced again but by the wrong stuff.
> > > Stopping all ajax calls was just one of my solutions, one that seemed
> > easy
> > > to implement if there was a way to do so. since no one seems very
> > confident
> > > in that I'm just look for some other way and assume this cannot be
> > done.
> >
> >
>

Reply via email to