Possible Duplicate:
How do you make javascript code execute *in order*
var cek = false;
function checkForm()
{
var user = document.forms["LoginForm"]["user"].value;
var pwd = document.forms["LoginForm"]["pwd"].value;
AJAXfunc("checkidpass.php?id="+user+"&pass="+pwd,function()
{
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200))
{
$("#LoginRes").html(xmlhttp.responseText);
if (xmlhttp.responseText == "")
cek = true;
}
}); //---> 1
return cek; //---> 2
}
I want to ask why "return cek;" (part 2) is executed before the AJAXfunc (part 1)? And I want to know how to make it executed in the right order.
Thanks for your help !