First of all I'm David, from Italy.
I recently started looking into your fabolous prototype thanks to this
script: http://tetlaw.id.au/view/javascript/really-easy-field-validation
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 & 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
-~----------~----~----~----~------~----~------~--~---