Answer the question
In order to leave comments, you need to log in
How to return the result of the component to a variable?
On the side of the ajax.php file, the sale.basket.basket.linetmp component (basket) is processed,
then the ajax file returns the result of the work in the form of html, and this html is added to the layout block on the frontend side.
ajax.php file code
define('STOP_STATISTICS', true);
define('NOT_CHECK_PERMISSIONS', true);
if (!isset($_POST['siteId']) || !is_string($_POST['siteId']))
die();
if (!isset($_POST['templateName']) || !is_string($_POST['templateName']))
die();
if ($_SERVER['REQUEST_METHOD'] != 'POST' ||
preg_match('/^[A-Za-z0-9_]{2}$/', $_POST['siteId']) !== 1 ||
preg_match('/^[.A-Za-z0-9_-]+$/', $_POST['templateName']) !== 1)
die;
define('SITE_ID', $_POST['siteId']);
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php');
if (!check_bitrix_sessid())
die;
$_POST['arParams']['AJAX'] = 'Y';
$APPLICATION->RestartBuffer();
header('Content-Type: text/html; charset='.LANG_CHARSET);
$APPLICATION->IncludeComponent('bitrix:sale.basket.basket.linetmp', $_POST['templateName'], $_POST['arParams']);
Answer the question
In order to leave comments, you need to log in
If it's fast, then copy the component to your namespace. And in your class.php or component.php file, output $arResult.
Or you can leave the template empty, and display $arResult in component_epolog.php as an option.
But I wouldn't do that. It's better to write a handler without using a component.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question