Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
AJAX fires success twice

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;
     }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Its calling the alert function when it is being set up and again when success is fired. try

success: function(data){
    alert("Account aangemaakt");
}
over 4 years ago · Santiago Trujillo Report

0

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;
     }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!