Hi All, I''m been playing with Ajax updating an element and it is working quite well. The only problem is if the user clicks the ''trigger'' multiple times, multiple ajax requests are created that are updating the same element. Since each Ajax request takes 2 seconds to run on my dev machine, as a user I can then see the form element get updated multiple times. It seems to me that if two Ajax requests are made that update the same element id, only the last request should be allowed to update the contents of the id and the result of the first request should be ignored. Is there anyway to accomplish this? I am concerned that without this functionality, it would be possible for the last Ajax request to be overridden by an earlier one, which could leave the UI in an inconsistent state (i.e. I have Javascript update a field and initiate the ajax). This problem is likely only occuring because I''m in development. Hopefully when it''s in production the user won''t be able to click fast enough to see this problem. However, if a user is on a modem, there will likely be enough latency to witness it. Thanks! --Dave.
On Monday 23 May 2005 23:59, David Teare wrote:> I''m been playing with Ajax updating an element and it is working > quite well. The only problem is if the user clicks the ''trigger'' > multiple times, multiple ajax requests are created that are updating > the same element. Since each Ajax request takes 2 seconds to run on > my dev machine, as a user I can then see the form element get updated > multiple times.Have you considered disabling the trigger to prevent repeat requests until the first one is handled? You don''t write how you''re doing the Ajax updates, however Ajax.Updater in prototype.js, as well as the rails helpers provide a mechanism to register a completion callback. Michael -- Michael Schuerig Life is just as deadly mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org As it looks http://www.schuerig.de/michael/ --Richard Thompson, Sibella
On 5/23/05, Michael Schuerig <michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org> wrote:> On Monday 23 May 2005 23:59, David Teare wrote: > > > I''m been playing with Ajax updating an element and it is working > > quite well. The only problem is if the user clicks the ''trigger'' > > multiple times, multiple ajax requests are created that are updating > > the same element. Since each Ajax request takes 2 seconds to run on > > my dev machine, as a user I can then see the form element get updated > > multiple times. > > Have you considered disabling the trigger to prevent repeat requests > until the first one is handled? You don''t write how you''re doing the > Ajax updates, however Ajax.Updater in prototype.js, as well as the > rails helpers provide a mechanism to register a completion callback. >Shouldn''t you disable the button/link on all Ajax requests? When wouldn''t you want to? Here''s another Ajax question: Is it possible yet to display (in a div) the status of a long-running (say, 5-10 seconds) operation? Say a user uploads an image and I have to process the image (make thumbnails, draw on it, save it to a bunch of locations etc). Is it possible to have the status of that stuff displayed on a web page? Thanks, Joe
That is exactly how upload process bars are implemented. You start upload process and register timer javascript function which polls the status of the upload process on the periodic basis from the server. Kent. On 5/23/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Here''s another Ajax question: Is it possible yet to display (in a > div) the status of a long-running (say, 5-10 seconds) operation? Say > a user uploads an image and I have to process the image (make > thumbnails, draw on it, save it to a bunch of locations etc). Is it > possible to have the status of that stuff displayed on a web page? >
On 5/23/05, Kent Sibilev <ksruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> That is exactly how upload process bars are implemented. You start > upload process and register timer javascript function which polls the > status of the upload process on the periodic basis from the server. > > Kent.Would doing something like what I want be easier in the next version of Rails (when the upload status thing might be included)? Joe> > On 5/23/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Here''s another Ajax question: Is it possible yet to display (in a > > div) the status of a long-running (say, 5-10 seconds) operation? Say > > a user uploads an image and I have to process the image (make > > thumbnails, draw on it, save it to a bunch of locations etc). Is it > > possible to have the status of that stuff displayed on a web page? > > >