XHR POST with FormData object sends as Request Payload instead of FormData
-
31-05-2023 - |
Domanda
I've read a handful of questions on Stack Overflow about this, but none seem to help.
I have a form, and I want to submit it. When I use a input type="submit", I can see in the headers the data goes up in the "Form Data" part of the header.
I then want to use XHR instead of the form's submit button.
I do:
var xhr = new XMLHttpRequest();
xhr.open("POST", "/url", true);
xhr.send(new FormData(document.getElementById("myform")));
Now in the header for this request, the data is there, but not in "Form Data", but in "Request Payload".
I think I can read the payload on my server (Java, Google App Engine) and parse it manually, I think. But that seems overkill.
Can I force the XHR to send the FormData as "Form Data" instead of "Request Payload"?
Nessuna soluzione corretta
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow