Mac에서 빠른 Ajax 실험을하고있었습니다. 스크립트/main.js 폴더에 다음과 같은 자바 스크립트 코드가 있습니다.Mac에서 localhost 문제를 어떻게 해결할 수 있습니까?
- index.html을
- JS/jquery.js
- JS/main.js I 버튼을 클릭 할 때마다
: 여기
'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');
});
}
};
내 작업 디렉토리 구조입니다 나는 다음을 얻는다 :
POST localhost:9000/data/customer.json 404 (Not Found)
failed
말했다되고 있다는 몇 가지 언급 할 필요가 :
나는 내가 localhost/~username/folder/file.php
로 이동했다 Sites/
폴더 아래에 내 프로젝트에 액세스하려면, PHP 개발을 수행하는 데 사용됩니다.
Forbidden
You don't have permission to access/on this server.
내가 httpd.conf 파일에 보니
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all #change here
</Directory>
에
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
를 수정 : 브라우저에서 localhost
를 입력 내 컴퓨터에 현재
Not Found
The requested URL/was not found on this server.
/~username/..
을 추가하지 않고 직접 내 localhost 폴더에 액세스 할 수 없다는 것이 내 문제라고 생각합니다.
알려 주시기 바랍니다. 여기
나는 같은 결과를 얻습니다. [link] (http : // localhost/~ username/ajax_test/data-manager)로 갈 때.php) 다음이 화면에 표시됩니다 : 요청 된 URL : /~roland/ajax_test/data-manager.php –
'data-manager.php'에 액세스하는 경우 올바른 응답입니다. '/ data/some-file'(.htaccess 파일의 위치) 에코 응답을 가져 오십시오. HTTP 요청에서 '/ ~ username /'이름을 제거하기 위해 'DocumentRoot'매개 변수를 httpd.conf 파일의 './~username/'경로로 변경하려고 했습니까? –
이 방법의 문제점은 Sites 폴더에있을 때만 'localhost/~ username /'폴더로 리디렉션된다는 것입니다. 난 쓸데없는 또는 파이썬 서버를 사용하는 경우라고 생각하지 않습니다 –