4
Friends, could you explain to me and if possible, give a solution to the following problem?
Man if
where it is written:
if(aux == 0)
{
console.log("não encontrado");
}
It is running before check in firebase, this only the first time I open the application. Below is the code of my function:
var refUser = new Firebase("//endereçodofirebaseescondido");
var key;
function logar() {
var aux = 0;
var login = document.getElementById("form1").elements.namedItem("login").value;
var pass = document.getElementById("form1").elements.namedItem("senha").value;
refUser.orderByChild("login").equalTo(login).on("child_added", function(snapshot) {
key = snapshot.key();
refUser.orderByChild("pass").equalTo(pass).on("child_added", function(snap) {
aux = 1;
console.log(pass);
if (key == snap.key()) {
console.log("senha e login conferem");
} else {
console.log("não encontrado");
}
});
});
if (aux == 0) {
console.log("não encontrado");
}
}
It’s not clear exactly what the problem is. You’re finding it odd to log in "not found", that’s it?
– Pablo Almeida
That’s it. I click the button and it automatically executes that last if. I would like a solution for that if only executed after the most above part is executed.
– Cleyton Silva