I am not getting any data from serializing my html form. Here is the form
<form method="post" action="#" name='basicForm' id='basicForm'>
<input type="text" name="n_username" id="id_username" class="form-control uname" placeholder='Username' value='test_user' data-msg-required='The input field is required.' data-rule-required='true'/>
<input type="password" name="n_password" id="id_password" class="form-control pword" placeholder='Password' value='xxxx' data-msg-required='The input field is required.' data-rule-required='true'/>
<button class="btn btn-success btn-block">Sign In</button> </form>
and here is the jquery
jQuery(document).ready(function(){
$("#basicForm").validate({
submitHandler: function (form) {
var request;
var $form = $(this);
var $inputs = $form.find("input, select, button, textarea");
var serializedData = $form.serialize();
alert (serializedData); <==empty
$inputs.prop("disabled", true);
request = $.ajax({
url: "./ajax/login.php",
type: "post",
data: serializedData
});
request.done(function (response, textStatus, jqXHR) {
// log a message to the console
console.log("Hooray, it worked!");
alert(response);
//window.location.replace("success.php");
});
}
}); //validate
});//ready
</script>
The data in the form is not serialised. I get an empty alert box. Also on the ajax page i postback to i print_r the $_post array and get this: Array()
I have checked the form elements have names which seems to be the common problem. I am using this jquery version
The validation works fine. This also works
var x = $("#id_username").val();
var y = $("#id_password").val();
request = $.ajax({
url: "./ajax/login.php",
type: "post",
//data: serializedData
data : {
username : x,
password: y
}
thanks in advance for any help you can give
$(this)
within the callback function, so his$form
is empty.