Answer the question
In order to leave comments, you need to log in
How to make ajax form with saving results in admin panel?
Hello!
What is the best way to implement a form (ajax) so that the results are stored in the admin panel and a notification with the filled data is sent to the administrator's mail (or to a separately registered mail).
on the Internet I came across different implementations both through main: feedback and through iblock.element.add and through bittrix: form.result.new. but since I'm not really into Bitrix yet - I don't quite understand how it's better and more correct.
Thank you)
Answer the question
In order to leave comments, you need to log in
You asked a lot of questions in one post.
Here's a great example:
<?
$el = new CIBlockElement;
$PROP = array();
$PROP[12] = "Белый"; // свойству с кодом 12 присваиваем значение "Белый"
$PROP[3] = 38; // свойству с кодом 3 присваиваем значение 38
$arLoadProductArray = Array(
"MODIFIED_BY" => $USER->GetID(), // элемент изменен текущим пользователем
"IBLOCK_SECTION_ID" => false, // элемент лежит в корне раздела
"IBLOCK_ID" => 18,
"PROPERTY_VALUES"=> $PROP,
"NAME" => "Элемент",
"ACTIVE" => "Y", // активен
"PREVIEW_TEXT" => "текст для списка элементов",
"DETAIL_TEXT" => "текст для детального просмотра",
"DETAIL_PICTURE" => CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"]."/image.gif")
);
if($PRODUCT_ID = $el->Add($arLoadProductArray))
echo "New ID: ".$PRODUCT_ID;
else
echo "Error: ".$el->LAST_ERROR;
?>
<script type="text/javascript">
$(function () {
$('#form_id').submit(function(e){
e.preventDefault();
var data = $(this).serialize();
$. ajax ({
url:'/ajax.php',
type:'post',
data:data,
success:function(res){
$('#result').html(res);
}
})
})
})
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question