We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46204
    • 5 Posts
    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
      • 4172
      • 5,888 Posts
      did you allready try to put your snippet-call onto a resource (with empty template) and use its url as the connector-url.

      Do you have the same issues then?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 46204
        • 5 Posts
        No I didn't try. is runSnippet buggy?
          • 4172
          • 5,888 Posts
          no, it isn't buggy.
          But may be, something else within your connector.

          If the resource-method is working, you know something is wrong with the connector.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 46204
            • 5 Posts
            connector is also working in the server. if I print anything there its working. but don't execute the snippet that I specified in the runSnippet