- From: <block.rxckin.beats@gmail.com>
- Date: Tue, 9 Dec 2014 08:01:39 +0900
- To: Anne van Kesteren <annevk@annevk.nl>
- Cc: "whatwg@whatwg.org" <whatwg@whatwg.org>
in form submit ``` <form id="myform" method="post" name="myform" action="/server"> <input type="number" name="id" value="123456"> <input type="text" name="username" value="jxck"> <input type="submit"> </form> ``` sends ``` username=jxck&id=123456 ``` in xhr with form data from same form ``` <script> var myform = document.getElementById('myform'); myform.addEventListener('submit', function(e) { e.preventDefault(); var xhr = new XMLHttpRequest(); xhr.open('POST', '/'); xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded"); xhr.send(new FormData(myform)); }); </script> ``` ``` ------WebKitFormBoundaryIieqlAAUtjBHtKc1 Content-Disposition: form-data; name="id" 123456 ------WebKitFormBoundaryIieqlAAUtjBHtKc1 Content-Disposition: form-data; name="username" jxck ------WebKitFormBoundaryIieqlAAUtjBHtKc1-- Response Headersview source ``` I think its not intuitive behavior. It seems that xhr should respects Content-Type or FormData should exports serialize format option for me. What is the motivation to "not support" except multipart format in FormData ? thanks Jxck 2014-12-08 19:16 GMT+09:00 Anne van Kesteren <annevk@annevk.nl>: > On Sat, Dec 6, 2014 at 9:33 PM, block.rxckin.beats@gmail.com > <block.rxckin.beats@gmail.com> wrote: > > but I wanna send string key/values in x-www-form-urlencoded format. > > Use URLSearchParams instead. FormData and ...-urlencoded are a bad > match due to Blob. > > > > because it's more standard way for web. > > The wire formats are equally standard, no? > > > -- > https://annevankesteren.nl/ >
Received on Monday, 8 December 2014 23:02:24 UTC