Answer the question
In order to leave comments, you need to log in
Ajax file upload and $arResult transfer (Bitrix)?
I'm doing a search on the site. There are 2 types of content display, grid and list. In the search.page template, I created 2 .php files, and depending on what is in the cookies, I include one of them. Switching between this display should be on ajax. How to implement all this correctly?
What I do: there is an ajax handler that, when clicked, sends me to a file in which I include one or another output template
$APPLICATION->IncludeFile(".../components/bitrix/search.page/search/".$_POST['TEMPLATE'].".php", array('arResult' => $arResult));
<?
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
$templateFolder = $this->GetFolder();
if (!empty($_POST) && $_POST["ACTION"] == "ChangeSearchView") {
$APPLICATION->IncludeFile($templateFolder."/".$_POST['TEMPLATE'].".php", array('arResult' => $arResult));
}
?>
Fatal error: Using $this when not in object context in .../components/bitrix/search.page/search/template.php on line 3
Answer the question
In order to leave comments, you need to log in
1. Option: in the settings of the component "AJAX_MODE" => "Y"
2. Option: depending on the request, connect a different template for the component. You frame the component with a div into which you will load the result of the ajax call.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question