This should really be simple. But the code I'm trying to write is just not working, even after searing around the internet.
So I have this. code to check if a user is online or offline.
//Check if it's a valid user
function checkUser(){
status = (function(){
var isOnline = null;
$.ajax({
async: false,
global: false,
type: "POST",
url: "./system/checkUser.php",
data: $("#webcam").serialize(),
success: function(data){
isOnline = (data == "1");
}
});
return isOnline;
})();
return status;
}
and this is how I try to use it
function loadProfile(){
var text = checkUser();
alert(text);
if(text != true){
alert("Invalid user!");
return;
}else{
//Code
}
But whatever I get from checkUser(), I always get the "Invalid user!" alert, even when text is true. Can anyone help me here? I'm lost for words.