Hi, I looked into the web, and I find that this is a common error, but I haven''t any solution.. My method Ajax.Request is in another method. And for my function(v), I need to put a return, false or true. I tried with my script, but it doesn''t work.. Have you any idea to solve my pb? Thanks My script : var valid = new Validation(''form-extra'', {immediate : true}); var resultat = false; Validation.add( ''validate-captcha'', ''Captcha is wrong!'', function(v){ new Ajax.Request( ''ajax_serve.php'', { method: ''get'', parameters: { validate: v }, onSuccess: function( transport ) { if( transport.responseText.match(/true/)) { $(''captcha'').removeClassName(''validation-failed''); $(''captcha'').addClassName(''validation-passed''); resultat = true; } else { $(''captcha'').removeClassName(''validation-passed''); $(''captcha'').addClassName(''validation-failed''); resultat = false; } } }); return resultat; }); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''ve always found it easier to use evalScripts:true in the Ajax call and spit back a script to call a function do do whatever I need. On Jul 4, 10:20 am, cdams <dams...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I looked into the web, and I find that this is a common error, but I > haven''t any solution.. > > My method Ajax.Request is in another method. And for my function(v), I > need to put a return, false or true. > I tried with my script, but it doesn''t work.. > > Have you any idea to solve my pb? > > Thanks > > My script : > > var valid = new Validation(''form-extra'', {immediate : true}); > var resultat = false; > > Validation.add( ''validate-captcha'', ''Captcha is wrong!'', function(v){ > new Ajax.Request( ''ajax_serve.php'', { > method: ''get'', > parameters: { > validate: v > }, > onSuccess: function( transport ) { > if( transport.responseText.match(/true/)) { > $(''captcha'').removeClassName(''validation-failed''); > $(''captcha'').addClassName(''validation-passed''); > resultat = true; > } else { > $(''captcha'').removeClassName(''validation-passed''); > $(''captcha'').addClassName(''validation-failed''); > resultat = false; > } > } > }); > return resultat; > > });--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
What do you mean? Can you develop a little your solution? On 4 juil, 17:11, Diodeus <diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve always found it easier to use evalScripts:true in the Ajax call > and spit back a script to call a function do do whatever I need. > > On Jul 4, 10:20 am, cdams <dams...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > I looked into the web, and I find that this is a common error, but I > > haven''t any solution.. > > > My method Ajax.Request is in another method. And for my function(v), I > > need to put a return, false or true. > > I tried with my script, but it doesn''t work.. > > > Have you any idea to solve my pb? > > > Thanks > > > My script : > > > var valid = new Validation(''form-extra'', {immediate : true}); > > var resultat = false; > > > Validation.add( ''validate-captcha'', ''Captcha is wrong!'', function(v){ > > new Ajax.Request( ''ajax_serve.php'', { > > method: ''get'', > > parameters: { > > validate: v > > }, > > onSuccess: function( transport ) { > > if( transport.responseText.match(/true/)) { > > $(''captcha'').removeClassName(''validation-failed''); > > $(''captcha'').addClassName(''validation-passed''); > > resultat = true; > > } else { > > $(''captcha'').removeClassName(''validation-passed''); > > $(''captcha'').addClassName(''validation-failed''); > > resultat = false; > > } > > } > > }); > > return resultat; > > > });--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Web page: function writeLog(someValue) { //write to appliction log now = new Date() url = ''http://somewhere/Logger.php?CMD=''+someValue+''&now=''+now new Ajax.Request(url, { method: ''get'', evalScripts:true }); } function writeComplete(someResponse) { alert(someResponse) } - - - Logger.php output: <script type="text/javascript"> writeComplete(''MOO'') </script> On Jul 4, 11:40 am, cdams <dams...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What do you mean? > > Can you develop a little your solution? > > On 4 juil, 17:11, Diodeus <diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''ve always found it easier to use evalScripts:true in the Ajax call > > and spit back a script to call a function do do whatever I need. > > > On Jul 4, 10:20 am, cdams <dams...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi, > > > > I looked into the web, and I find that this is a common error, but I > > > haven''t any solution.. > > > > My method Ajax.Request is in another method. And for my function(v), I > > > need to put a return, false or true. > > > I tried with my script, but it doesn''t work.. > > > > Have you any idea to solve my pb? > > > > Thanks > > > > My script : > > > > var valid = new Validation(''form-extra'', {immediate : true}); > > > var resultat = false; > > > > Validation.add( ''validate-captcha'', ''Captcha is wrong!'', function(v){ > > > new Ajax.Request( ''ajax_serve.php'', { > > > method: ''get'', > > > parameters: { > > > validate: v > > > }, > > > onSuccess: function( transport ) { > > > if( transport.responseText.match(/true/)) { > > > $(''captcha'').removeClassName(''validation-failed''); > > > $(''captcha'').addClassName(''validation-passed''); > > > resultat = true; > > > } else { > > > $(''captcha'').removeClassName(''validation-passed''); > > > $(''captcha'').addClassName(''validation-failed''); > > > resultat = false; > > > } > > > } > > > }); > > > return resultat; > > > > });--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You can''t do what you want because the Ajax call completes asynchronously - the function won''t know what value to return yet by the time it completes. You either need to have your return script execute some code as one responder suggested, or have your onSuccess/onComplete handler call some other function when it''s finished to alert your page that the Ajax call completed. Instead of returning the result, call another function instead: function myCallback(returnValue) { /// ajax call completed with returnValue } new Ajax.Request(.... { onSuccess: function (transport) { ..... myCallback(result); } ); -Fred On Fri, Jul 4, 2008 at 9:20 AM, cdams <damsvdf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > I looked into the web, and I find that this is a common error, but I > haven''t any solution.. > > My method Ajax.Request is in another method. And for my function(v), I > need to put a return, false or true. > I tried with my script, but it doesn''t work.. > > Have you any idea to solve my pb?-- 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 -~----------~----~----~----~------~----~------~--~---