Javascript无法访问root之外的php脚本

时间:2014-01-13 00:58:10

标签: php ajax directory

我的文件夹结构:

/public
   /css
   /fonts
   /images
   /js
   index.php
/resources
   /configs
   /library
   /scripts
   /templates

我的问题是validate.js(位于/ js)无法访问validate.php(位于/ scripts中)。

$.ajax( {

    type: "POST",
    url: "../resources/scripts/validate.php",

谢谢!

更新,这是错误信息:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /resources/scripts/validate.php was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
<hr>
<address>Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7 Server at localhost Port 80</address>
</body></html>

3 个答案:

答案 0 :(得分:1)

尝试

$.ajax( {

    type: "POST",
    url: "../../resources/scripts/validate.php", 

答案 1 :(得分:1)

php脚本应该能够访问它。

创建

/public/cgi/myvalidate.php

<?php include '../../resources/scripts/validate.php'; ?>

$.ajax( {

    type: "POST",
    url: "cgi/myvalidate.php",

或将validate.php放在可以公开访问的位置。

答案 2 :(得分:0)

$.ajax( {

    type: "POST",
    url: "../resources/scripts/validate.php",