I have a code that checks if a user exists in my database through an xmlhttprequest in this case. For some reason when I tell it to return true, I get undefined. I have no idea what the problem could be here. The function exists in an object window._
also _.xhr()
just basically creates an xmlhttprequest and is very similar to jquery's $.ajax method.
vu: function(u,c){
if(typeof c==="undefined"){
c=null;
}
if(c!==""&&c!==null){
alert(c); //when alert is executed here the result is a string "true" as it should be. Since kiddo is an user in my database
if(c=="true"){
return true;
}
return false;
}
_.xhr({
method:"get",
adress:"../php/include/functions.php?function=user_exists&a="+u,
asyn:true,
headers:{"Content-Type":"application/x-www-form-urlencoded"},
ready:function(e){
alert(e)
_.vu.call(_.vu,u,e); //<-- This is a callback.
}});
}