I''m new to the forum and I have what I assume will be a basic question for a lot of you... I am using Ajax.Updater to make async calls to my service. I am calling the same function three times so I can populate three different divs. My issue is I would like to have a loading indicator that shows when I start and doesn''t hide until the last call is complete. Below is my function: As you can see, I have a call to checkAllCalls() which is my attempt to hide the indicator only after everything is loaded. It works but only ocassionally. Just curisous if someone has a better approach. I just want to show one indicator for all three calls that disappears when all the data is loaded. function executeCall(day, inDiv, inURL, inParams, inSync) { reqDay = day; var opt = { method: ''get'', postBody: inParams, on404: function(t) { alert(''Error 404: location "'' + t.statusText + ''" was not found.''); }, onFailure: function(t) { ErrorHandler(t); }, asynchronous: inSync } new Ajax.Updater(inDiv + ''Container'', inURL, opt); setTimeout(''checkAllCalls()'', 1000); }
Check the Responders class... http://www.sergiopereira.com/articles/prototype.js.html#Ajax.Responders You can register your callback function to hide the div there. -Jerod On 8/8/06, TLADAMSO-uNZObgmCpkU@public.gmane.org <TLADAMSO-uNZObgmCpkU@public.gmane.org> wrote:> > I''m new to the forum and I have what I assume will be a basic question for > a lot of you... > > I am using Ajax.Updater to make async calls to my service. I am calling > the same function three times so I can populate three different divs. My > issue is I would like to have a loading indicator that shows when I start > and doesn''t hide until the last call is complete. Below is my function: > > As you can see, I have a call to checkAllCalls() which is my attempt to > hide the indicator only after everything is loaded. It works but only > ocassionally. > > Just curisous if someone has a better approach. I just want to show one > indicator for all three calls that disappears when all the data is loaded. > > > function executeCall(day, inDiv, inURL, inParams, inSync) { > reqDay = day; > > var opt = { > method: ''get'', > postBody: inParams, > on404: function(t) { > alert(''Error 404: location "'' + t.statusText + ''" > was not found.''); > }, > onFailure: function(t) { > ErrorHandler(t); > }, > asynchronous: inSync > } > new Ajax.Updater(inDiv + ''Container'', inURL, opt); > > setTimeout(''checkAllCalls()'', 1000); > } > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
That did the trick - thanks for help :-) |---------+--------------------------------------------> | | "Jerod Venema" | | | <jvenema-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> | | | Sent by: | | | rails-spinoffs-bounces-1W37MKcQCpIbvKGg9ot7NQ@public.gmane.org| | | onrails.org | | | | | | | | | 08/09/2006 06:15 PM | | | Please respond to rails-spinoffs | | | | |---------+--------------------------------------------> >------------------------------------------------------------------------------------------------------------------------------| | | | To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org | | cc: (bcc: Tyler L. Adamson/UPC) | | Subject: Re: [Rails-spinoffs] newbie question | >------------------------------------------------------------------------------------------------------------------------------| Check the Responders class... http://www.sergiopereira.com/articles/prototype.js.html#Ajax.Responders You can register your callback function to hide the div there. -Jerod On 8/8/06, TLADAMSO-uNZObgmCpkU@public.gmane.org <TLADAMSO-uNZObgmCpkU@public.gmane.org> wrote:> > I''m new to the forum and I have what I assume will be a basic questionfor> a lot of you... > > I am using Ajax.Updater to make async calls to my service. I am calling > the same function three times so I can populate three different divs. My > issue is I would like to have a loading indicator that shows when I start > and doesn''t hide until the last call is complete. Below is my function: > > As you can see, I have a call to checkAllCalls() which is my attempt to > hide the indicator only after everything is loaded. It works but only > ocassionally. > > Just curisous if someone has a better approach. I just want to show one > indicator for all three calls that disappears when all the data isloaded.> > > function executeCall(day, inDiv, inURL, inParams, inSync) { > reqDay = day; > > var opt = { > method: ''get'', > postBody: inParams, > on404: function(t) { > alert(''Error 404: location "'' + t.statusText + ''" > was not found.''); > }, > onFailure: function(t) { > ErrorHandler(t); > }, > asynchronous: inSync > } > new Ajax.Updater(inDiv + ''Container'', inURL, opt); > > setTimeout(''checkAllCalls()'', 1000); > } > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs