I wrestled with asynchronous calls like you have (and quite honestly,
found the structure associated with the onSuccess/onFailure lead to
confusing code)

I eventually settled on using
   var myAjax = new Ajax.Updater( <target>, <url>, {method: 'post',
parameters: pars, evalScripts: true} );
(AFAIK, 'evalScripts: true' does not seem to work with Ajax.Request...
someone please corrected me if I'm wrong)

I then code within the <url> to generate the scripts that should be
spawned on success or failure (and I can set things so that the
scripts don't get called until all of the prerequisite bits are
available).  Depending on the nature of the calls/results, I
occasionally set the <target> to a hidden <div>.

Once I settled on this approach, I had carefully (re-)structure my
code so that calls cascaded properly... i.e., I found that on
occasion, the same functions were getting spawned from
different<url>'s (meaning that the pages could regenerating things
unnecessarily).

Hope this helps,

Al

On Dec 20, 6:35 am, kangur91 <kangu...@gmail.com> wrote:
> My code:
>
> function get_data_default() {
> new Ajax.Request('/adress',
>   {
>     method:'post',
>     asynchronous:true,
>     onSuccess: function(data){ return data.responseText.evalJSON
> (true); },
>     onFailure: function(){ alert('Something went wrong...') }
>   });}
>
>             }
> function show(){alert(get_data_default());}
>
> I want to function get_data_default return data recived from OnSucces
> function. How do that?

--

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.


Reply via email to