S
S
Sergey2017-11-03 11:31:35
JavaScript
Sergey, 2017-11-03 11:31:35

Why isn't the form submitting only in the Safari browser (on iMac and iOS)?

The form is not submitted in the Safari browser (on iMac and iOS), when submitting the form - the page just reloads. All other browsers are ok.
Google doesn't even help.

Here is the ajax script
//E-mail Ajax Send
  $("#callback").submit(function() {
    var th = $(this);
    $.ajax({
      type: "POST",
      url: "mail.php",
      data: th.serialize()
    }).done(function() {
      $(th).find(".success").addClass("active").css("display", "flex").hide().fadeIn();
      setTimeout(function() {
        $(th).find(".success").removeClass("active").fadeOut();
        th.trigger("reset");
      }, 4000);
    });
    return false;
  });

But the form itself
<form class="form-lease" id="callback">
                        <div class="success"><span>Спасибо за заявку!</span></div>

                        <!-- Hidden Required Fields -->
                        <input type="hidden" name="project_name" value="site">
                        <input type="hidden" name="admin_email" value="[email protected]">
                        <input type="hidden" name="form_subject" value="description">
                        <!-- END Hidden Required Fields -->

                        <div class="row">

                            <div class="col-sm-6 wow slideInLeft">
                                <label>
                                    <span>Ваше имя</span>
                                    <input type="text" name="Имя" required><br>
                                </label>

                                <label>
                                    <span>Телефон</span>
                                    <input type="text" name="Телефон" required>
                                </label>

                                <label>
                                    <span>E-mail</span>
                                    <input type="email" name="E-mail" required>
                                </label>
                            </div>

                            <div class="col-sm-6 wow slideInRight">
                                <label>
                                    <span>Сообщение</span>
                                    <textarea rows="5" name="Сообщение" required></textarea>
                                </label>

                                <button class="btn-sub" type="submit">Отправить</button>    
                            </div>

mail.php file:
<?php

$method = $_SERVER['REQUEST_METHOD'];

//Script Foreach
$c = true;
if ( $method === 'POST' ) {

  $project_name = trim($_POST["project_name"]);
  $admin_email  = trim($_POST["admin_email"]);
  $form_subject = trim($_POST["form_subject"]);

  foreach ( $_POST as $key => $value ) {
    if ( $value != "" && $key != "project_name" && $key != "admin_email" && $key != "form_subject" ) {
      $message .= "<b>" . $key . "</b>: " . $value . "<br>";
    }
  }
} else if ( $method === 'GET' ) {

  $project_name = trim($_GET["project_name"]);
  $admin_email  = trim($_GET["admin_email"]);
  $form_subject = trim($_GET["form_subject"]);

  foreach ( $_GET as $key => $value ) {
    if ( $value != "" && $key != "project_name" && $key != "admin_email" && $key != "form_subject" ) {
      $message .= "<b>" . $key . "</b>: " . $value . "<br>";
    }
  }
}

function adopt($text) {
  return '=?UTF-8?B?'.Base64_encode($text).'?=';
}

$headers = "MIME-Version: 1.0" . PHP_EOL .
"Content-Type: text/html; charset=utf-8" . PHP_EOL .
'From: '.adopt($project_name).' <'.$admin_email.'>' . PHP_EOL .
'Reply-To: '.$admin_email.'' . PHP_EOL;

mail($admin_email, adopt($form_subject), $message, $headers );

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
fl3nkey, 2017-11-03
@FLUNKEY

$("#callback").on('submit', function(e) {
  e.preventDefault();
});

S
Sergey, 2017-11-03
@fenya-fl

All decided. There was a mismatch with another plugin.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question