hi, i've moved the logic to the handler onComplete but i have several requests with in a for statement, so i supose i would need a synchronous request.
could i have any problem or shoul i take anything into account? ___________ it is a very specific requirement, so i think it doesn't worth to put the code just in case, ive uploaded a snippet of the code im using here: http://grijalbo.freetzi.com/prov/snippet.js ___________ On Jun 30, 12:43 pm, ljundie <[EMAIL PROTECTED]> wrote: > hi T.J., > > i'll follow your advices and the API Docs ones "Since synchronous > usage is rather unsettling, and usually bad taste, you should avoid > changing this. Seriously." ;) > > it helps a lot, > many thanks :) > > On Jun 30, 12:06 pm, "T.J. Crowder" <[EMAIL PROTECTED]> wrote: > > > 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 -~----------~----~----~----~------~----~------~--~---