let edit = document.querySelector("#edit");
edit.addEventListener("submit", (e) => {
e.preventDefault();
fetch("/project/write",
{
method: 'POST',
cache: 'no-cache',
body: new FormData(edit)
})
.then(response => response.json())
.then(jsonResult => {
console.log(jsonResult.status);
if(jsonResult.status)
alert("업로드 처리 성공");
location.href = jsonResult.url;
});
});
일일이 json으로 보낼 데이터를 지정하지 않아도 된다.