I have a form with one input field and submit button. I know the name of the button can be submitted but for some reason, it isn't being posted to the server.
$(document).ready(function(){
$("form").submit(function(e) {
e.preventDefault();
console.log($(this).serialize());
return false;
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form method="post">
<div class="a">
<label>Name</label>
<input name="projectName" type="text">
</div>
<div class="b">
<input name="newProject" value="Save Project" type="submit"></div>
</form>
output: projectName=abc
Expected output: projectName=abc
, newProject=Save Project
Why is the "newProject" name not being sent to the server?