\Bitrix\Main\EventManager::getInstance()->addEventHandler(
'main',
'OnBeforeLocalRedirect',
'formBeforeRedirect'
);
function formBeforeRedirect($redirectUrl) {
parse_str(parse_url($redirectUrl, PHP_URL_QUERY), $query);
if (!empty($query['WEB_FORM_ID']) && !empty($query['formresult'])) {
die(json_encode([
'error' => 0,
'message' => ''
]));
}
}