Celeritas
Celeritas

Reputation: 15043

Trouble accessing file in other directory using Ajax, am I specifying the path wrong?

In WAMP I changed the root directory from C:\wamp\www to C:\wamp\www\public. I have a file named username.html it communicates through Ajax with simple.php. This works fine if simple.php is in C:\wamp\www\public but if I move it to C:\wamp\www\private nothing happens.

NOTE I elected not to use jquery and am doing this with plain javascript.

xmlhttp.open("GET", "simple.php?suite="+top,true);//works when simple.php is in same folder

xmlhttp.open("GET", "..\private\simple.php?suite="+top,true);//doesn't work

xmlhttp.open("GET", "../private/simple.php?suite="+top,true);//doesn't work

xmlhttp.open("GET", "..//private//simple.php?suite="+top,true);//doesn't work

Upvotes: 0

Views: 173

Answers (1)

Miro Hudak
Miro Hudak

Reputation: 2215

That is because now, public is your webroot and you are requesting the site from the webserver. The "private" directory is out of the reach of your webserver, because is out of the webroot. You can access it directly from your PHP script (i.e. via fopen(), include, require,... if it is allowed in security settings), but webserver can not serve it directly.

Upvotes: 1

Related Questions