In my application, I'm firing a AJAX request to php script, which is outside modx. but I included modx `index.php` to get global `$modx` variable. like below
define('MODX_API_MODE', true);
if(array_key_exists('CONTEXT_DOCUMENT_ROOT', $_SERVER)) {
$strRootPath = $_SERVER['CONTEXT_DOCUMENT_ROOT'];
}
else {
$strRootPath = $_SERVER['DOCUMENT_ROOT'];
}
/** @var $modx \modX */
require_once $strRootPath . '/index.php';
$output = $modx->runSnippet('snippetName', array('param' = 'value'));
echo $output;
AJAX request is working and browser get 200 response, for all ajax request this script execute. but Its not running this snippet all time. like for 10 request runSnippet execute 2/3 times.
other scripts are working properly. this is working on apache server properly (though apache server got less load) but randomly working on nginx server (it has high traffic).
Let me know if anymore clarification needed.
Thanks