I have the following input field:
<input id="dataRequest" type="text" method="POST" border=None value=""/>
and developed code that responds to the following cURL command.
curl -v --insecure -H "Content-Type: application/x-www-form-urlencoded" -X POST -d 'dataRequest=demo1' https://localhost:443
Entering a value into the input field does not work.
Question 1: Why does the cURL code work when filling in the field does not?
Question 2: I am trying to use Javascript to create a button that will submit the equivalent command (to cURL) when pressed.
This is what I have so far, but it does not work (nothing happens).
<button onclick="runDemo1()" name="button1" value="demo1">
<script>
function runDemo1() {
let formData = new FormData();
formData.append("dataRequest", "demo1");
let xhr = new XMLHttpRequest();
let page = window.location.host;
xhr.open("POST", page, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(formData);
}
</script>
XMLHttpRequest. The--insecureflag isn't convertable to Javascript.