I am trying to learn jQuery. Working on an employee website that will allow entry via a unique keypad code for each employee. Anyways, came across this script and am having a hell of a time getting it to function as I would expect.
Here is my form:
<form name='keypad_test' class='form-inline' method='post' role="form" >
<div class='form-group'>
<label for='user_id'></label>
<div class='col-sm-10'>
<input type='password' id='user_id' name='user_id' class='keypad' disabled='disabled' />
</div>
</div>
Here is how I am being forced to get the variable. I want to use serialization for the data, but I can't get it to work to save my life.
<script type="text/javascript">
$('form').submit(function(e) {
var user_id_var = $('input.keypad').val();
$.post("process.php", { user_id:user_id_var }, function(data) {
alert(data);
});
process.php
is just $user_id = $_POST["user_id"]; echo $user_id;
Is it possible for someone to tell me what I need to do to serialize the data so I know it is clean? My solution so far was taking bits from different answers on this post here.