M
M
m4son2018-11-12 17:00:52
1C-Bitrix
m4son, 2018-11-12 17:00:52

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>

And there is code for page 2:
<? 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", "", "");

The question is that everything works, the letter arrives, but the answer is fail. Why ?

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