I have a working request I've created in Postman. In this request, I'm POSTing data to an endpoint at http://localhost:21124/submissions/[someId]. In Postman, I have a Header key called Content-Type with a value of application/x-www-form-urlencoded.
In the Body tab in Postman, I have the x-www-form-urlencoded radio button selected. I then have a number of key-value pairs entered. When I POST this request, it works successfully. I'm now trying to rebuild this request as an HTML form.
In an attempt to rebuild the request as an HTML form, I have:
function submitClick() {
var form = $('#myForm');
$.ajax({
url: '/submissions/2e5f7619-23a5-425c-a39c-97928e3c2f9a',
data: form.serialize(),
type: 'POST'
});
return false;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="myForm" method="post">
<label for="emailAddress">Email address</label>
<input type="email" id="emailAddress">
<label for="name">Name</label>
<input type="text" id="name">
<button onclick="return submitClick();">Submit</button>
</form>
When I click the "submit" button, I'm not seeing my values in my controller. I can successfully see them when I post via Postman. This would mean that the values are getting POSTed two different ways. However, I'm not sure why. Can someone please explain the difference to me?
Thanks
<input>elements "name" attributes or else they'll be ignored.