-1

Mac で簡単な Ajax の実験を行っていました。script/main.js フォルダーに次の JavaScript コードがあります。

'use strict';
 var button = document.getElementsByClassName('update');

button[0].addEventListener('click', function() {
    worker.updateCustomer();
});

var worker = {
    updateCustomer: function(customerInfo, cb) {
        $.ajax({
            url: 'data/customer.json',
            type: 'POST',
        }).done(function(data) {
            log('response', data);
        }).fail(function() {
            log('failed');
        });
    }
};

これが私の作業ディレクトリ構造です:

  • index.html
  • js/jquery.js
  • js/main.js

ボタンをクリックするたびに、次のようになります。

POST localhost:9000/data/customer.json 404 (Not Found)
failed

そうは言っても、いくつか言及する必要があります。

Sites/以前は PHP 開発を行っていたので、フォルダーの下にあるプロジェクトにアクセスするには、 に移動する必要がありましたlocalhost/~username/folder/file.php

現在私のマシンでlocalhostは、ブラウザに入力すると次のように返されます。

Forbidden
You don't have permission to access / on this server.

httpd.conf を調べて変更しました

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all  #change here
</Directory>

そして今取得します:

Not Found

The requested URL / was not found on this server.

私の問題は、追加せずに localhost フォルダーに直接アクセスすること/~username/..が不可能であるという事実によるものだと思います。

お知らせ下さい。

4

1 に答える 1