We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24806
    • 43 Posts
    There is this ajax-index.php file. Is it possible to give a pure snippet output or something like this for Ajax in a page where normally a template is around and how to do this? How to use that ajax-index.php-file?

    regards,
    Max
      I love MODx
      • 22303 MODX Staff
      • 10,725 Posts
      You don’t need index-ajax.php; just create a snippet and place it on a page with no template and have that snippet generate your Ajax response. Nice and simple.
        • 24806
        • 43 Posts
        Yeah, that is what I did in the past but it would look nicer if your snippets simply work with ajax without creating a new document cool.
        I thought that there would be the possibility to fill a special variable which only outputs in the ajax-index.php without the other content and without a template.
        Anyway, what is that index-ajax.php for?

        regards,
        Max
          I love MODx
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          The reason for all this is that the various MODx classes have to be loaded to enable the modx library functions. So at the very least it needs the config.inc.php file and the document parser class. You can write your own php backend without using the modx libraries; I’ve done that often enough, but the libraries do make things much easier.
            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