I have the following XmlHttpRequest:
var poc = new XMLHttpRequest();
poc.open("POST", URL);
poc.setRequestHeader("CUSTOM-HEADER", extract);
poc.send();
console.log("Request sent with header");
I'm wanting to submit POST body data alongside this XHR. Let's say the HTTP POST request is as follows:
POST /user/updateField/1554 HTTP/1.1
Host: localhost
Connection: close
Content-Length: 142
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytxuXi4RTyonGC5pD
------WebKitFormBoundarytxuXi4RTyonGC5pD
Content-Disposition: form-data; name="access"
winner
------WebKitFormBoundarytxuXi4RTyonGC5pD--
How can I add this to the above JavaScript XmlHttpRequest?
If it makes it easier, how could I submit the winner value through HTTP form data via JavaScript?:
<html>
  <body>
  <script>history.pushState('', '', '/')</script>
    <form action="https://localhost:4442/user/updateField/1554" method="POST" enctype="multipart/form-data">
      <input type="hidden" name="access" value="winner" />
      <input type="submit" value="Submit request" />
    </form>
   <script>
   document.forms[0].submit();
  </script>
  </body>
</html>
Your help is much appreciated, thank you!
