D
D
Daniil Sukhikh2018-04-13 12:59:04
PHP
Daniil Sukhikh, 2018-04-13 12:59:04

Ajax request not working in Mozilla, how to fix it?

jquery-3.2.1.min
There is code to submit the question form:
HTML:

<div id="fin">
    <div id="finO">
      <p></p>
      <button class="closefin" type="button">Закрыть</button>
    </div>
  </div>
<form id="formabout" method="POST">
  <p><input placeholder="Имя" required id="aname" type="text" name="name"></p>
  <p><input placeholder="Электронная почта" required id="amail" type="email" name="email"></p>
  <p><textarea placeholder="Вопрос" required id="atext" name="text"></textarea></p>
  <button type="button" id="addabout" name="abut">Задать вопрос</button>
  <div class="infp"></div>
</form>

PHP:
<?php
require '../libs/bd.php';
$date = $_POST;
if (isset($date['name']) and isset($date['email']) and $date['text']) {
  $name = $date['name'];
  $text = $date['text'];
  $email = $date['email'];
  $abres = mysqli_query($connection, "INSERT INTO `about`(`name`, `text`, `email`) VALUES ('$name', '$text', '$email')");
  if ($abres == true) {
    $fin = "Сообщение отправлено!";
  }

}
?>

jQuery:
function funcSucc(date) {
    $('#fin').fadeIn();
    $('#finO p').text('Вопрос успешно отправлен!')
  };

  $('#addabout').click(function() {
    var name = $('#aname').val();
    var email = $('#amail').val();
    var text = $('#atext').val();
    if (text == '' || email == '' || name == '') {
      $('#fin').fadeIn();
      $('#finO p').css({"color": "#f23232"})
      $('#finO p').text('Вопрос не отправлен! Заполните все поля.')
    } else {
      $.ajax ({
      url: "/script/about.php",
      type: "POST",
      data: ({name, email, text}),
      dataType: "text",
      success: funcSucc
      });
    };
  });

The problem is that everything is sent in Google, but not in Mozilla ...
I did not test it in other browsers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stimulate, 2018-04-13
@danchiksux

$('#addabout').click(function(event) {
    event.preventDefault();
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question