Hi, Yes, you can set/modify global variables in any function in JavaScript. Did you try it and have a problem, or...?
I should note that your code above won't work as you expect it to, because the request is asynchronous. So the code checking whether foo is 1 runs immediately, before the request has a chance to finish. Once the request finishes and the onComplete handler fires, though, foo will be set to 1. (You can make the request synchronous, but it's not a great idea; better to put your logic in the various completion handlers.) Hope this helps, -- T.J. Crowder tj / crowder software / com On Jun 30, 9:51 am, ljundie <[EMAIL PROTECTED]> wrote: > hi! > > i still dont manage to do everything i need with prototype callbacks. > one thing i'd like to get is to be able to change a global value > within a callback, is it possible? > > an example better than thounsand words ;) > the code would be like: > > <script type="text/javascript"> > > var foo=0; > > function loadRSS() { > var url = "feeds.xhtml"; > var myAjax = new Ajax.Request( url, { > > method: 'get', > > parameters: '', > > onComplete: processRSS > > }); > } > > function processRSS(xmlHttpRequest, responseHeader) { > foo=1; > } > > if (foo==1){ > alert ('yeah!'); > } > > </script> > > many thanks in advance for every help --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---