안녕하세요, 재생 프레임 워크에서 내 메소드에 문자열을 보내려고하지만 제출 버튼을 클릭 한 후 내 콘솔에서 500 (내부 서버 오류) 오류가 발생합니다.Play Framework의 AJAX 게시물
$("#submit").click(function() {
$.ajax({
url: "@routes.Application.upload()",
data: JSON.stringify(filename),
headers: {
'Content-Type': 'application/json'
},
type: 'POST',
success: function(res) {
if (res) {
console.log("Success!");
} else {
console.log("Failed...");
}
}
});
return false;
});
내 양식 : 여기
<form id="#idForm">
<input type="file" name="file" id="file">
<input id="submit" type="submit">
</form>
및
public static Result upload() {
JsonNode node = request().body().asJson().get("stringField");
String inputString = node.asText();
System.out.println(inputString) ; }
당신이 나를 좀 도와 드릴까요 내 업로드 방법 여기에 내 프런트 엔드 코드입니다.
데이터를 기능에 게시하려고합니까? url : "@ routes.Application.upload()", <- 어쩌면 실제 URL을 시도해보십시오. – britter
@britter @ routes.Application.upload()는 기본적으로/업로드 중입니다. 난 둘 다 나에게 같은 오류'POST http://127.0.0.1:9000/upload 500 (내부 서버 오류)' –
을 제공하려고했는데 당신이 서버에서 얻은 오류를 보여줄 수 있습니까? 콘솔 출력을 보거나 Chrome 또는 Firefox를 사용하는 경우 Network in dev 도구를 확인하십시오. – Salem