Answer the question
In order to leave comments, you need to log in
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
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 = "Сообщение отправлено!";
}
}
?>
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
});
};
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question