내 응용 프로그램의 모든 양식에 사용해야하는 React-component를 작성했습니다. 특정 단추를 클릭하면 유효성 검사가 완료되고 마지막으로 서버에 양식을 게시하려고합니다. Chrome
에서Internet Explorer 11에서 fetch-api를 통해 FormData-object를 게시 할 때 빈 값
// get what should be submitted
const formData = new FormData(theForm)); // theForm is the DOM-element
// post the form-data element
fetch(theForm.action,
{
credentials: "include", //pass cookies, for authentication
method: theForm.method,
headers: {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
//"Content-Type": "application/x-www-form-urlencoded"
},
body: formData
})
.then(res => console.dir(res))
.catch(reason => console.error(reason));
표시 된 니펫을 잘 작동 : 이이 부분이 현재 모습입니다. 그러나 IE11
에서는 그렇지 않습니다. 한편, Content-Type
헤더의 주석 처리를 제거하면 Chrome
으로 중단됩니다.
발견 된 바와 같이 https://stackoverflow.com/a/46642899/615288은 항상 "multipart/form-data"
입니다. 그러나 그것을 multipart/form-data
으로 설정하더라도 값은 서버로 전송되지 않습니다.
https://github.com/jimmywarting/FormData의 FormData 폴리필과 whatwg-fetch
을 사용하고 있습니다.
내가 무엇을 FormData 버전부터 IE에서 작동합니다 여기에 벌어지고 표시되지 9.
(!) 참고 : 브라우저가를 추측 보인다 여전히 Chrome
에서 작동 전체 헤더 부분을 주석 때 올바른 것 (개발자 도구에서 볼 수 있듯이)