Holding Down Enter Causes A Lot Of Ajax Requests

I’m using AJAX for a search form where the user can limit the number of returned results through a search. This is working well, and the user can just press Enter to perform a search. The problem I have is that if I hold in Enter, I can generate a lot of POST requests. From a performance perspective, I’d like to limit this somehow. Any ideas of how this limiation can be achieved? Is it done in the view file or the controller file?

Right now, I have this to enable the Enter feature:


That’s one way. But with onkeyup i can just press enter over and over again with the only difference that I let go of the key. Can I have some type of timeout, max 20 searches in 40 seconds or something like that? :)

There are different ways to solve this but the most easiest is to disable the button before doing the request… and enable it again after the request is completed.

That works if I only have a submit button to press. But what if I have made it possible to submit by pressing enter. Then that solution will not work. Any other way to do it?

it all depends on your code… I guess you have some event handler for the ENETER key… for that case you can set some status variable so to know you are processing the first ENETER… and clear that status when the processing is done…