You could do:
function stateChanged()
{
if (request.readyState==4)
{
OnStateChanged(request.responseText);
}
}
Where OnStateChanged
is a function that act as an event handler...
EDIT: in OnStateChanged
you can then submit or not your form based on response
EDIT2: On the server when you check the u/p, if they're right log the user right on and return the status to JavaScript.. then in the JavaScript instead of resubmitting a form, just reload/redirect the page if it is successful or display an alert otherwise...
It is just not possible to return something from a function by an asynchronous operation in it... the original thread of execution is long gone. The asynchronous operation is executed by another thread (If I remember correctly, don't flame).
Thanks