In connection with my other question: Context-sensitive AJAX call on a modular site , is it possible to configure AJAX proxies in a convenient way?
I would like to make AJAX requests with a dynamic url without messing up the JavaScript code using server side PHP instructions, calculating the correct path for the ajax php file on the Apache / PHP / MySQL modular site, a crude 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 for dynamically restoring their folders. I would like:
$("#mydiv").load(siteRoot + "/ajax.php?plugin=datagrid&
action=myaction&... other params...");
will call instead (with a server-side url using PHP):
{siteRoot}/components/datagrid/ajax/myaction.php?... other params ...
(obviously with all possible checks against injections, CSRF and other hacks).
source
share