Perhaps turn that logic around: Rather than giving the value back to the PE and letting it decide whether to stop, you could pass the PE to the request function and have the request decide whether to stop the PE:
em = function(url, pe) { var percent; new Ajax.Request(url, { method: 'get', onSuccess: function(transport) { var Bar = $('emBar'); percent = transport.responseText; Bar.setStyle({ width: percent + '%' }); if (parseInt(percent) > LIMIT) { pe.stop(); } } }); } Alternately, wrap all of this in an object where both the request and the PE are members, and the object has a method used by the success callback to decide whether to stop. Or, of course, use a global. But that would be wrong. :-) FWIW. -- T.J. Crowder tj / crowder software / com On May 28, 6:04 am, PAOEGONVG <[EMAIL PROTECTED]> wrote: > I have a ajax request in a function like so: > > em = function(url) > { > var percent; > new Ajax.Request(url, > { > method: 'get', > onSuccess: function(transport) > { > var Bar = $('emBar'); > percent = transport.responseText; > Bar.setStyle({ width: percent + '%' }); > } > }); > > } > > And then I have another function that has a PeriodicalExecuter that > runs the first function. > The problem is I can't figure out how to make it so the first function > returns the percent variable so that the PeriodicalExecuter will stop > when it hits a certain number. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---