I do not understand what the problem is. There is a snippet in which I invoke my class. with direct access, everything is ok (/cart/save.html) And when I pull this page through ajax (POST), he says that he cannot find the class that I call in that snippet

Fatal error: Class 'lib\cabinet\User' not found in /var/www/******/core/cache/includes/elements/modsnippet/23.include.cache.php on line 5 

enter image description here

The problem is that with a POST request, for some reason, classes are not loaded, and if you send a GET request, then everything is ok.

    2 answers 2

    If I'm not mistaken in modx defined constants, MODX_BASE_PATH, etc. why use $_SERVER['DOCUMENT_ROOT'] , try this:

     require_once(MODX_BASE_PATH.'/lib/cabinet/api.php'); 

    And mine in modx to make an ajax request, you must first create a resource in the admin panel, at least in modx> 2.2.8

    • so if the problem were with file uploading there would be a corresponding error. The problem is that for some reason he doesn’t see the class - Pavel Dura

    Try this:

     require_once '../lib/cabinet/api.php';