Try daisy chaining them... let the onComplete of one function initiate the
ajax call for the next query.
// initiate the first ajax Query
function ajaxFuncFirst(url)
{
url = url +".php";
new Ajax.Updater( 'result', url, {method: 'post', parameters:
$('myform').serialize(), onSuccess: ajaxFuncFirst_Results, onFailure:
ajax_err, on0: ajax_err});
}
// onComplete of first query, it'll call the 2nd ajax query
function ajaxFuncFirst_Results()
{
// do some processing here (i.e. fill in list box)
ajaxFuncSecond("query2url");
}
// this is the 2nd query which gets called at the end of the onComplete of
the first query
function ajaxFuncSecond(url)
{
url = url +".php";
new Ajax.Updater( 'result', url, {method: 'post', parameters:
$('myform').serialize(), onSuccess: ajaxFuncSecond_Results, onFailure:
ajax_err, on0: ajax_err});
}
function ajaxFuncSecond_Results()
{
// do some processing here (i.e. fill in list box)
ajaxFuncThird("query3url");
}
// this is the 3rd query which gets called at the end of the onComplete of
the fsecond query
function ajaxFuncThird(url)
{
url = url +".php";
new Ajax.Updater( 'result', url, {method: 'post', parameters:
$('myform').serialize(), onSuccess: ajaxFuncThird_Results, onFailure:
ajax_err, on0: ajax_err});
}
function ajaxFuncThird_Results()
{
// do some processing here (i.e. fill in list box)
ajaxFuncFourth("query4url");
}
// show's we're processing (ajax swirly icon)
// and hides the submit button
function showProcessing()
{
if(Ajax.activeRequestCount > 0)
$('submit').hide();
document.getElementById('inProgress').style.display = 'inline';
}
// hide's the fact that we're processing which shows processing is completed
// this will also unhide the submit button
function hideProcessing ()
{
if(Ajax.activeRequestCount <= 0)
document.getElementById('inProgress').style.display = 'none';
$('submit').show();
}
On Wed, Sep 22, 2010 at 7:50 AM, Kupido <[email protected]> wrote:
> Hello,
> I'm looking for a reliable way to call a function after the previous
> one has completed.
>
> I'm not new to Prototype but I can't find a way to call n functions
> sequentially... is Function.defer meant for this?
>
> Thanks in advance.
>
>
> --
> 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
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<prototype-scriptaculous%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
>
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.