Answer the question
In order to leave comments, you need to log in
What is the error in the form submission code in 1s-Bitrix?
There is a code for page 1:
<form action="add_form_result.php" method="POST">
Тема
<input type="text" name="theme" value="">
Текст анонса
<input type="text" name="mess">
<input type="hidden" name="login" value="<?=$arUser['LOGIN'];?>">
<input type="hidden" name="name" value="<?=$arUser['NAME'];?>">
<input type="submit" value="Отправить">
</form>
<script>
$(function() {
$('form').submit(function(e) {
var $form = $(this);
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize()
}).done(function() {
console.log('success');
lert("success");
}).fail(function() {
console.log('fail');
alert("fail");
});
//отмена действия по умолчанию для кнопки submit
e.preventDefault();
});
});
</script>
<? require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
$NAME = htmlspecialcharsbx($_POST["name"]);
$LOGIN = htmlspecialcharsbx($_POST["login"]);
$THEME = htmlspecialcharsbx($_POST["theme"]);
$MESS = htmlspecialcharsbx($_POST["mess"]);
$arEventFields = array(
"NAME" => $NAME,
"LOGIN" => $LOGIN,
"MESS" => $MESS,
"THEME" => $THEME
);
CEvent::Send("MY_SEND_MESS", "s1", $arEventFields, "N", "", "");
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