Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.4.1

Request #14022 Delay needed when typing to prevent flooding
Submitted: 2008-05-30 05:58 UTC
From: shangxiao Assigned:
Status: Open Package: HTML_QuickForm_Livesearch (version 0.4.0)
PHP Version: 5.2.6 OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2008-05-30 05:58 UTC] shangxiao (David Sanders)
Description: ------------ A delay is needed when typing into the livesearch text field to prevent flooding the AJAX server with requests every time a key is pressed. Eg: In the application that I'm setting up, users will type the name of a school. Schools here are often named after their suburb. There might be 3-4 schools in the one suburb. Eg: A suburb called Hawthorn might have "HawthornPrimary School", "Hawthorn Secondary School", "Hawthorn North Primary School", etc. The user will typically start typing "Hawthorn" until a shortlist appears that they can just navigate to. Typically in the past I've always setup delays so that the ajax server isn't flooded with unnecessary requests for "H", "Ha", "Haw", "Hawt", ...., etc. I've found a delay of 250ms to be beneficial, but of course, you'd want to make this an option that you can modify. I'd be happy to upload a patch if you need.

Comments

 [2008-05-30 08:17 UTC] thesee (Giuseppe Dessi)
Please, review the example you can find in the package. there is an option called "buffer". 'buffer' => 350, //set the interval single buffer send time (ms) Let me know if it works :)
 [2008-05-30 09:32 UTC] shangxiao (David Sanders)
Right well when I read the example and saw "buffer" I had no idea what that meant. Perhaps the option name should be changed to something more instantly recognisable like "buffer_delay". But I suppose that'd be up to you, 'buffer' seems ok now that I think about it. To be sure that this setting did what you said it does, I set the "buffer" to 2000ms and I'm still seeing multiple requests, albeit only 2. If I type "2awthorn" as fast as I can type, the server still sees a request for "h" and then for "hawthorn" 2 seconds later. But perhaps this is a bug with HTML_AJAX.
 [2008-05-30 09:33 UTC] shangxiao (David Sanders)
(PS : "2awthorn" should've been "hawthorn")
 [2008-06-02 11:28 UTC] shangxiao (David Sanders)
I've confirmed that this is expected behaviour of HTML_AJAX_Queue_SingleBuffer. It will immediately send the first request. I've asked a question on the HTML_AJAX mailing list whether in the future this could be disabled. Yet to hear a response.
 [2008-06-03 04:04 UTC] shangxiao (David Sanders)
Please see Joshua Eichorn's response; He is happy to change the behaviour of the single buffer queue: http://www.nabble.com/SingleBuffer-Queue-Behaviour-td17556963.html This will also require a patch here to accommodate the api change
 [2008-06-03 06:16 UTC] shangxiao (David Sanders)
Ok now after playing around with the single buffer queue, I've realised that this queue is not what should be used by livesearch. The single buffer queue will send out a request to the ajax server every x milliseconds from the point that you start typing. So I think this feature request still stands. Livesearch should implement it's own timeout and delay-send immediate requests using HTML_AJAX_Queue_Single (which is the default I believe).