Skip to content

Instantly share code, notes, and snippets.

@qwertik17
Created June 3, 2019 07:51
Show Gist options
  • Save qwertik17/43f20bd86406854e7df8630fa7740302 to your computer and use it in GitHub Desktop.
Save qwertik17/43f20bd86406854e7df8630fa7740302 to your computer and use it in GitHub Desktop.
webconnector for ajax requests in frontend
<?php
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/config.core.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$modx->getService('error', 'error.modError', '', '');
$path = MODX_CORE_PATH.'components/ajax/processors/web/';
$response = $modx->runProcessor($_REQUEST['action'], $_REQUEST, array(
'processors_path' => $path
));
$json = $modx->toJSON($response->response);
echo $json;
@session_write_close();
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment