는 :
같은 양식 PUT과 같은 방법을 사용하여, 우리는 HTTP 방식을 변경하는 데 사용할 수있는 _method라는 이름의 숨겨진 입력을 활용할 수 있습니다. 그렇게하기 위해서 우리는 먼저 formParser 아래에 배치되어야하는 methodOverride 미들웨어가 필요합니다. 그래서 폼 값을 포함하는 req.body를 활용할 수 있습니다.
그래서 :
app.use(express.bodyParser());
app.use(express.methodOverride());
그리고 당신의 형태로
:
<input type="hidden" name="_method" value="put">
업데이트 : 아스 커의 새로운 의견을 알고있는 것처럼는 nrph은 양식을 제출하는 방법을 원한다 ajax를 사용하여 PUT
메소드 다음은 jQuery를 사용하는 솔루션입니다.
// Use this submit handler for all forms in document
$(document).on('submit', 'form', function(e) {
// Form being submitted
var form = e.currentTarget;
// Issue an ajax request
$.ajax({
url: form.action, // the forms 'action' attribute
type: 'PUT', // use 'PUT' (not supported in all browsers)
// Alt. the 'method' attribute (form.method)
data: $(form).serialize(), // Serialize the form's fields and values
success: function() {},
error: function() {}
});
// Prevent the browser from submitting the form
e.preventDefault();
});
아약스 방식으로 처리되도록 생성 된 풋 매핑이 아닙니까? – nrph
실례합니다. 나는 그 질문을 이해하지 못한다. –
이 http://stackoverflow.com/a/7257509/450441 코멘트에 따르면 대부분의 최신 브라우저는 XMLHttpRequest로 PUT을 지원합니다. 따라서 아약스가 표현을 통해 값을 제출하는 가장 확실한 옵션이어야한다는 아이디어를 제공합니다. – nrph