Ajax is asynchronous. You cannot you use a return value. You must use a callback:
ret("user", function(check) {
if (check == true)
.. run ..
});
And you can implement ret
like this:
function ret(as, callback) {
....codes...
$.ajax({
type: "POST",
url: "../../03",
data: "as="+as,
success: function (msg) {
if(msg == 'true' ){
..codes..
callback(true);
}else{
..codes..
callback(false);
}
}
});
}
Another option would be to force the request to be synchronous, but that's not really the idiomatic way of doing it.