-3
I’m trying to use async to return the amount the bank will bring, but it’s not working
async function emailExi(email){
const teste = await $.ajax({
url: "../banco/emailexi.php",
method: "POST",
data: {email: email},
success: function(data){
console.log(data)
return data
}
})
}
I am testing with a console.log(), and returns promisse{pending}
Here’s the version with the then, I don’t know if it’s right
async function emailExi(email){
const teste = await $.ajax({
url: "../banco/emailexi.php",
method: "POST",
data: {email: email},
}).then(function(data){
return data
})
}
var tr = emailExi("aa")
console.log(tr)
So I have 2 functions:
function valiEmail(email){
let erro = false
if (emailExi(inputEmail)){
erro = "email já existe. Por favor coloque outro email"
}
return erro
}
async function emailExi(email){
const teste = await $.ajax({
url: "../banco/emailexi.php",
method: "POST",
data: {email: email},
})
return teste
}
i want to return if it is true or false there for valiEmail function, how do I do this?
Have you tried using the
then
to capture the information?– Woss
I tried, but I don’t know if I did it right
– alguemAi