L
L
Loner972019-02-25 00:37:34
AJAX
Loner97, 2019-02-25 00:37:34

Why doesn't beforeSend work, the button doesn't turn off and emails are sent more than once (how many times you can click)?

<script>

  $('#modal_form1').submit(function(){
    var form = $(this);
    var data = form.serialize();
        $.ajax({
          type: "POST",
          url: "mailer/smart3.php",
          data: data,
      beforeSend: function() { 
                form.find('input[type="submit"]').attr('disabled', 'disabled'); 
              }
        }).done(function() {
          form.find("input").val("");
          $('#callModal1').modal('hide');
       window.location = "https://12345";
          $("#modal_form1").trigger("reset");
     
        });
        return false;
      });
  
</script>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question