laravel. 아약스 호출을 사용하여 laravel을 사용하여 API를 만들고 싶습니다. 하지만 아약스 전화를 요청하면 URL에 잘못된 서버 경로가 표시됩니다. 다음은 내 코드입니다
내 경로 파일 :Laravel Ajax가 컨트롤러에 URL을 호출합니다.
Route::get("a/b","[email protected]");
내 JS 파일 :
var base = "public/index.php";
var url = base + "a/b";
$.ajax({
url : url,
dataType: "json",
timeout: 10000,
error:function(){ alert("Error getting from server") }
}).done(function(resp){
});
내가 다음 URL에서한다고 가정입니다 :
이domain.com/dev/lar/public/index.php/c/d
가 그럼 난 후,이 아약스를 호출 URL이
domain.com/dev/lar/public/index.php/c/public/index.php/a/b
로 리디렉션됩니다.
여기 고맙다 내 laravel 응용 프로그램 폴더
** Note I am using NGINX server. My Server Admin do not rewrite this url. That's why I use public/index.php **
이 코드의 경로를 시도해야합니다 : ("/ A/B", "AController의 @의 C")를 얻을; Route :: get ("a/b", "AController @ c") 대신; –
내 앱 폴더가 도메인 다음에 많은 하위 폴더이므로이 경로가 작동하지 않습니다. ex- domain.com/dev/{laravel app folder} – Alien
domain.com/dev/lar/public/index.php/c/d domain.com/dev/lar/public/c/d를 사용하는 이유는 무엇입니까? 당신은 index.php 디렉토리가 아닌 파일을 만들까요 ??? –