Forum Moderators: open

Message Too Old, No Replies

Multiple AJAX = nothing?

Using onkeyup, inputting too fast returns nothing.

         

Br3nn4n

11:57 am on Aug 18, 2009 (gmt 0)

10+ Year Member



Hi,

I have an ajax script I'm using that simply checks if a username is available (does a REALLY simple mysql_query).

It's triggered onkeyup. Now, if I type slow it seems to work. If I type fast, it (after a couple characters) stops returning anything (like too many AJAX requests are happening?)

Any way I can check if there's already a request processing? Or ... not sure really, how would you fix this?

Thanks!

daveVk

3:08 pm on Aug 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Any way I can check if there's already a request processing?

Null the location where the ajax reply goes, Null = busy, Ok there are probably better ways that handle all error conditions, but that should suffice.

Also consider inserting small delay before sending, reset after each keystroke, so fast typing will not trigger search early.

Br3nn4n

9:30 pm on Aug 18, 2009 (gmt 0)

10+ Year Member



So if I have a span with an id, how can I null it? Sounds like a feasible idea :)

Also I'm thinking I can have my ajax function check if there's a already a request going and stop it (and start the new one). I tried using setTimeout to make it wait a second or two (thus eliminating a new request the moment a user types a letter).

daveVk

1:13 am on Aug 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So if I have a span with an id, how can I null it? Sounds like a feasible idea :)

Maybe change the class of the span to "busy", can also act as visual indication if desired.

Also I'm thinking I can have my ajax function check if there's a already a request going and stop it

Yes, this will depend upon what library, if any, you use.

You may not gain must be canceling request, as sql request has probably started, simpler ? to wait for reply and issue new request.

I tried using setTimeout to make it wait a second or two

Even a fraction of a second delay will help a lot. A key a second is slow.