Jonny .. i wrote this a few months back and forgot about it ...
Its the basics you will need to achieve what you want to do .... Any questions please ask http://proto-scripty.wikidot.com/prototype:how-to-throttle-ajax-requests Regards Alex ----- Original Message ----- From: "Alex Mcauley" <webmas...@thecarmarketplace.com> To: <prototype-scriptaculous@googlegroups.com> Sent: Sunday, March 01, 2009 7:21 PM Subject: [Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing issue > > there is a completely easier way to do what you want and save memory on > the > client side and serverside ... > > If you can wait till monday i will post the code for you to do it > > > Regards > Alex > > ----- Original Message ----- > From: "Jonny Nott" <jonn...@gmail.com> > To: "Prototype & script.aculo.us" > <prototype-scriptaculous@googlegroups.com> > Sent: Saturday, February 28, 2009 12:12 PM > Subject: [Proto-Scripty] Ajax.Updater home-brew autocompletion timing > issue > > >> >> I use the following Ajax.Updater code to auto-complete (refresh) the >> options within a select box according to text entered into an input >> [type=text]. >> >> The code is part of a function which is envoke by the 'onkeyup' event >> on the input: >> >> new Ajax.Updater(targetSelect.identify(), xhrRequestUrl, { >> method: 'get', >> parameters: { >> match: inputControl.getValue() >> }, >> onCreate: targetSelect.disable.bind(targetSelect), >> onSuccess: (function(){ >> targetSelect.enable(); >> }).bind(targetSelect) >> }); >> >> The problem: with large data sets, the ajax requests take long time to >> process on the server, and then there's network lag, etc. This returns >> in (sometimes) the responses come back in the wrong order. An example: >> >> - user types 'abc', which sets off 3 requests, with 'match' param of >> 'a', 'ab', 'abc' respectively. >> - due to server delay/network lag etc, sometimes the response for >> 'abc' comes back *before* the 'ab' response >> - select box ends up containing all entries match 'ab', rather than >> only those matching 'abc' >> >> The solution I've thought of: >> >> Somehow make a callback function which short-circuits (i.e. aborts) >> the Ajax.updater object if it's 'match' parameter is different from >> the current value of 'inputControl' at the point where it's about to >> empty and replenish the select box with the HTML from the response. >> Issues: >> >> - Which callback will allow me to intercept Ajax.updater at this >> point? Will this even work with Ajax.updater, or do I need to use >> Ajax.request and update the contents of the select box element >> manually if the condition for doing so are met? >> - How can a callback access the 'parameters' which were set for the >> request? Can it even? Will I need to duplicate 'match' into some local >> variable - and even then how will the anonymous callback function get >> at it? >> >> Am I barking up the wrong tree altogether? >> >> Jon >> >> > >> > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---