We can change the document root path for PHP using
$_SERVER['DOCUMENT_ROOT'] = "to/some/new/directory";
in .htaccess we have
RewriteBase "/to/some/new/directory"
Now I need to change the root path of the directory to use in javascript. How to do it?
I am currently declaring a variable containing a static path to my personal root directory and use it as
var root = "../to/new/path";
document.location = root+"/somepage.php";
Scenario
I think I should tell you a little about the script, because you guys will catch my idea
Default web root directory
http_docs/
inside it contains the main folder
http_docs/application <-- contains the actual application
http_docs/js <-- contains the script
http_docs/index.html
Now the application also contains an ajax function for updating, editing, downloading new content or other resources, which, if access to "/" will be displayed in / some / path / i /, are called not / application / some / path / i / is called,
var root = "application/";
-
$.post(....., function(data) { $(body).append("<img src='"+root+"resources/img1.jpg"); });
, , , , , , js-. , , , PHP, <img src="/resources/img1.jpg" />
, , , , . , .