That’s because Revo works differently. Personally, even with Evo I always use a resource (no template, just the AJAX processing code in a snippet) for the AJAX URL. No need to load another instance of the parser or anything else.
Did you see this? http://modxcms.com/forums/index.php/topic,57373.0.html
Custom Connectors
A Connector is essentially a PHP file whose main purpose is to provide a connection between an AJAX-based request, and a Processor file. Since Processors are usually involved in CRUD (create, read, update, and delete) operations on a database, they should never be accessed directly. Instead, by using a Connector as a proxy to connect to a Processor, additional authentication and security checks can be performed before allowing access to the Processor.
Unlike Controllers, which are used in the Manager to display an actual page (and belong in your component’s /core/ directory), Connectors must be HTTP-accessible. Therefore, it’s best to place them in your component’s /assets/ directory. Now, let’s take a look at the structure of a Connector file.
The first thing your Connector must do is include the MODx configuration file, as well as the main MODx Connector file.
1
2
3
4
5
6
<?php
$basePath = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) );
require_once $basePath . ’/config.core.php’;
require_once MODX_CORE_PATH . ’config/’ . MODX_CONFIG_KEY . ’.inc.php’;
require_once MODX_CONNECTORS_PATH . ’index.php’;
Next, we simply have to ’handle’ the, or pass the request data on to the appropriate Processor file.
1
2
3
4
5
$modx->request->handleRequest( array(
’processors_path’ => $modx->getOption( ’core_path’ ) . ’components/mycomponent/processors/’,
’location’ => ’’
) );
?>
As you can see, handleRequest() accepts an array of options:
processors_path: The base directory where your component’s processor files are found.
location: The subdirectory of processors_path to find the processor.
action: This tells MODx the filename of the Processor file to load. This value will be taken from the HTTP $_REQUEST[’action’] parameter.
That’s all there is to it! Your AJAX requests simply need to call your Connector file (with an ’action’ parameter referring to the appropriate Processor file), and voila -- you can now use AJAX requests in your component!