We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24714
    • 19 Posts
    Everything is in the subject.
    There’s NO index_ajax.php in revo...

    The only thing I’ve found - stupid tutorial about jQuery tabs which isn’t even ajax...
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      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
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 24714
        • 19 Posts
        Quote from: sottwell at May 04, 2011, 12:59 PM

        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

        I did the same, untill realised, that this way for 1 ajax call modx make 2 queries to bd...

        1)Take content of resource and if there is some code to...
        2)make other calls...

        For instance i made trend.ges66.ru (sorry - it’s in russian)and there are some difficult ajax queries while scrolling the content of the page...

        All i wanted to say - that id want my php quered here and now through Ajax, why should I always stick to resource tree.

        PS. sorry for bad english =)
          • 24714
          • 19 Posts
          I’ve fuckin found it... strange thing that it was in documentation...
          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!