2

In reference of my other question: Context-aware AJAX call in a modular site , is it possible to set up an AJAX proxy in a convenient way?

I’d wish to make AJAX requests with dynamic url without tainting the JavaScript code with server-side PHP instructions, computing the right path for the ajax php file in a modular Apache/PHP/MySQL site, a rough CMS written by me.
In other words, the site has plugins and components with their own folder structures containing their CSS, JS, and PHP and I have functions to retrieve their folder dynamically. I’d wish that:

$("#mydiv").load(siteRoot + "/ajax.php?plugin=datagrid&
action=myaction&... other params...");

will instead call (with the URL computed server-side by PHP):

{siteRoot}/components/datagrid/ajax/myaction.php?... other params ...

(obviously with all the possible checks against injections, CSRF and other hacks).