I am trying to pass a checkbox value of modal form using AJAX but without checking the check-box. Whenever I click on the submit button it automatically selects the checkbox and sends its value. Why is all that happening?
<div class="checkbox">
<label>
<input type="checkbox" name="remember" id="remember" <?php if(isset($_COOKIE['username'])) { ?> checked <?php } ?>>
Remember me
</label>
</div>
$('#login_Modal').click(function(e) {
e.preventDefault();
var username = $('#loginUsername').val();
var password = $('#loginPassword').val();
var remember = $('input[name="remember"]').prop('checked');
if ($("#loginUsername").val() === '') {
$("#loginUsername").parent().addClass('has-error');
$("#loginUsername").focus();
//errCount++;
} else if($("#loginPassword").val() === '') {
$("#loginPassword").parent().addClass('has-error');
$("#loginPassword").focus();
} else {
$("#loginUsername").parent().removeClass('has-error').addClass('has-success');
$.ajax({
url: "form_login_process.php",
type: 'POST',
data: {
'Username': username,
'Password': password,
'Remember' : remember
},
success: function(data) {
alert(data);
}
The AJAX response shows "on"
.
Aucun commentaire:
Enregistrer un commentaire