У меня есть фильтр где выводятся города, при клике по селекту идёт ajax запрос с айди города в компонент
$(function(){
$('.select-item').on('click', function(){
var select = document.getElementById('someId');
var opti = select.options[select.selectedIndex].value;
$.ajax({
method: "post",
url: "/news.php",
data: {
"city_id": opti
},
success: function(data) {
console.log(opti);
$('.tranings__item').html(data);
},
error: function(er) {
console.log(er);
}
});
});
})
в компоненте делаю фильтр arrfilter, и в него запихиваю $_POST['city_id'] но это так не работает, подскажите как правильно?
код компонента
<?
global $arrfilter;
$arrfilter = ['PROPERTY_CITY_INFO' => ['PROPERTY_VALUE_ID' => $_POST['city_id']]]; ?>
<?$APPLICATION->IncludeComponent(
"bitrix:news.list",
"",
Array(
"ACTIVE_DATE_FORMAT" => $arParams["LIST_ACTIVE_DATE_FORMAT"],
"ADD_SECTIONS_CHAIN" => "N",
"AJAX_MODE" => "Y",
"AJAX_OPTION_ADDITIONAL" => "N",
"AJAX_OPTION_HISTORY" => "N",
"AJAX_OPTION_JUMP" => "N",
"AJAX_OPTION_STYLE" => "N",
"CACHE_FILTER" => "N",
"CACHE_GROUPS" => "N",
"CACHE_TIME" => $arParams["CACHE_TIME"],
"CACHE_TYPE" => "A",
"CHECK_DATES" => "N",
"DETAIL_URL" => $arResult["FOLDER"].$arResult["URL_TEMPLATES"]["detail"],
"DISPLAY_AS_RATING" => $arParams["DISPLAY_AS_RATING"],
"DISPLAY_BOTTOM_PAGER" => "Y",
"DISPLAY_DATE" => "N",
"DISPLAY_NAME" => "Y",
"DISPLAY_PICTURE" => "N",
"DISPLAY_PREVIEW_TEXT" => "N",
"DISPLAY_TOP_PAGER" => "N",
"FIELD_CODE" => array("PREVIEW_PICTURE","={$arParams["LIST_FIELD_CODE"]}",""),
"FILE_404" => $arParams["FILE_404"],
"FILTER_NAME" => 'arrfilter',
"HIDE_LINK_WHEN_NO_DETAIL" => "N",
"IBLOCK_ID" => $arParams["IBLOCK_ID"],
"IBLOCK_TYPE" => "-",
"IBLOCK_URL" => $arResult["FOLDER"].$arResult["URL_TEMPLATES"]["news"],
"INCLUDE_IBLOCK_INTO_CHAIN" => "N",
"INCLUDE_SUBSECTIONS" => "Y",
"MAX_VOTE" => $arParams["MAX_VOTE"],
"MEDIA_PROPERTY" => $arParams["MEDIA_PROPERTY"],
"MESSAGE_404" => $arParams["MESSAGE_404"],
"NEWS_COUNT" => $arParams["NEWS_COUNT"],
"PAGER_BASE_LINK" => $arParams["PAGER_BASE_LINK"],
"PAGER_BASE_LINK_ENABLE" => "N",
"PAGER_DESC_NUMBERING" => "N",
"PAGER_DESC_NUMBERING_CACHE_TIME" => $arParams["PAGER_DESC_NUMBERING_CACHE_TIME"],
"PAGER_PARAMS_NAME" => $arParams["PAGER_PARAMS_NAME"],
"PAGER_SHOW_ALL" => "N",
"PAGER_SHOW_ALWAYS" => "N",
"PAGER_TEMPLATE" => $arParams["PAGER_TEMPLATE"],
"PAGER_TITLE" => $arParams["PAGER_TITLE"],
"PARENT_SECTION" => $arResult["VARIABLES"]["SECTION_ID"],
"PARENT_SECTION_CODE" => "",
"PREVIEW_TRUNCATE_LEN" => $arParams["PREVIEW_TRUNCATE_LEN"],
"PROPERTY_CODE" => $arParams["LIST_PROPERTY_CODE"],
),
$component
);?>