I’m sure this is something really simple…
I have the code below…
<script>
function postUser() {
var user = $('span').serialize();
$.post('userManagement/setUser', user);
}
</script>
<span>
Username : <input type="text" name = "userName"><br />
First name: <input type="text" name="firstName" /><br />
Last name: <input type="text" name="lastName" /><br />
Password: <input type="text" name="password" /><br />
<button onclick="postUser()">Submit</button>
</span>
Nothing gets posted (as in the POST is literally empty according to firebug).
How do I POST this form? I want to use jQuery just so I can get better at it rather than just putting it into the HTML. My controller is expecting a JSON object that’s just my user entity with the fields above as well as an integer for “access”.
I’m using SpringMVC for the controller.
Thanks,
Try this:
Then: