Reputation: 705
I have the following Javascript code. For some reason the ajax success option fires twice, I get two identical alerts.
if (message =="") {
$.ajax({
url: '/dev/php/register.php',
type: 'POST',
data: {firstname:voornaam,lastname:achternaam,email:email,password:wachtwoord,gender:gender,date:datum},
success: alert("Account aangemaakt")
})
}
else {
showSnackBar(message);
return false;
}
Upvotes: 3
Views: 609
Reputation: 705
I just fixed it by renaming the function to something random like wowwat. I don't know why this works.
if (message =="") {
$.ajax({
url: '/dev/php/register.php',
type: 'POST',
data: {firstname:voornaam,lastname:achternaam,email:email,password:wachtwoord,gender:gender,date:datum},
success: function(wowwat)
{
alert("Account aangemaakt");
}
})
}
else {
showSnackBar(message);
return false;
}
Upvotes: 0
Reputation: 1849
Its calling the alert function when it is being set up and again when success is fired. try
success: function(data){
alert("Account aangemaakt");
}
Upvotes: 7