First of all I'm David, from Italy.
I recently started looking into your fabolous prototype thanks to this

After some playing around I decided to add another validation check.
Without going into the details of the other script (which is not
relevent) I would like to ask you how can I return a variable AFTER an
Ajax request has finished.

This is the code:

function(v) {
                new Ajax.Request('availability.php',
                {method: 'get', parameters: {validate: v},
                onSuccess: function( transport ) {
                     if( transport.responseText.match(/true/)) {
                        risultato = false;
                else {
                risultato = true;
                return risultato;

The problem is that availability takes a long time to process the
response (1sec) and while he process the thing risultato has the value
of the last query.

For example: first time we have risultato = true;
so it returns: true
The second time I invoke the function i still have risultato = true
from before. Now the ajx request returns risultato = false BUT while
it goes the functions returns true.

How can I avoid this?

Thank you very much

You received this message because you are subscribed to the Google Groups 
"Prototype &" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to