hello back, another funny question with prototype callbacks :) i dont manage to get a callback return a value. the example would be: <script type="text/javascript"> var lucas = 0; function loadRSS() { var url = "sample_feeds/sample_feeds_TTblog.xhtml"; var myAjax = new Ajax.Request( url, { method: ''get'', parameters: '''', onComplete: lucas = processRSS }); } function processRSS(xmlHttpRequest, responseHeader) { value = 1; return value; } if (lucas==1) { alert (''ole!''); } </script> i''ve also tried, without any result, something like: onComplete: function (xmlHttpRequest, responseHeader) { lucas = processRSS(xmlHttpRequest, responseHeader); } every little help worths :) --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, Your first one doesn''t work for various reasons. The second one will work, but it has the same sync/async problem that your other thread suffers from. -- T.J. Crowder tj / crowder software / com On Jun 30, 9:51 am, ljundie <ljun...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hello back, another funny question with prototype callbacks :) > > i dont manage to get a callback return a value. the example would be: > > <script type="text/javascript"> > > var lucas = 0; > > function loadRSS() { > var url = "sample_feeds/sample_feeds_TTblog.xhtml"; > var myAjax = new Ajax.Request( url, { > method: ''get'', > parameters: '''', > onComplete: lucas = processRSS > }); > } > > function processRSS(xmlHttpRequest, responseHeader) { > value = 1; > return value; > } > > if (lucas==1) { > alert (''ole!''); > } > > </script> > > i''ve also tried, without any result, something like: > onComplete: function (xmlHttpRequest, responseHeader) { > lucas = processRSS(xmlHttpRequest, responseHeader); > } > > every little help worths :)--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
FYI, what you''re doing in this example is setting the value of lucas to the function processRSS immediately, and then handing that value to Ajax.Request as the onComplete handler. Syntactically it may look like it''s performing the assignment in the callback, but it isn''t. -Fred On Mon, Jun 30, 2008 at 3:51 AM, ljundie <ljundie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > var lucas = 0; > > function loadRSS() { > var url = "sample_feeds/sample_feeds_TTblog.xhtml"; > var myAjax = new Ajax.Request( url, { > > method: ''get'', > > parameters: '''', > > onComplete: lucas = processRSS > > }); > } >-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
To elaborate a little: lucas = processRSS is an expression like any other: lucas = processRSS 4 + 3 "My name is " + myName !myBoolean As with any other expression, it gets simplified first, and the onComplete property takes on that simplified value. In the case of the assignment operator (=), the expression simplifies to the value being assigned (in this case, a reference to the processRSS function). Best to avoid this syntax entirely - I''ve seen it used as sugar, but IMHO it''s just confusing. On Jun 30, 6:52 am, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:> FYI, what you''re doing in this example is setting the value of lucas to the > function processRSS immediately, and then handing that value to Ajax.Request > as the onComplete handler. Syntactically it may look like it''s performing > the assignment in the callback, but it isn''t. > > -Fred > > > > On Mon, Jun 30, 2008 at 3:51 AM, ljundie <ljun...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > var lucas = 0; > > > function loadRSS() { > > var url = "sample_feeds/sample_feeds_TTblog.xhtml"; > > var myAjax = new Ajax.Request( url, { > > > method: ''get'', > > > parameters: '''', > > > onComplete: lucas = processRSS > > > }); > > } > > -- > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---