I have a form, of which I am trying to get the values this way, but it is not working. Where am I going wrong?
JQuery
<script type="text/javascript">
$(document).ready(function(){
data = $('#login-form').serialize();
$.post("validar.php", {
d: data,
},
function (d) {
console.log(data);
$('#myModal').modal('show');
});
return false;
});
</script>
Console result:
TypeAccess = Select & LoginAccess = & AccessPassword =
Form
<form method="post" id="login-form">
<ul>
<li>
<label>Tipo de Acesso:</label>
<select id="tipoAcesso" class="form-control" name="TipoAcesso" onChange="alterar(this.value);">
<option value="Selecione">Selecione</option>
<option value="Aluno">Aluno</option>
<option value="Responsável">Responsável</option>
<option value="Professor">Professor</option>
<option value="Coordenador">Coordenador</option>
<option value="Secretaria">Secretaria</option>
<option value="Adm. Escola">Adm. Escola</option>
</select>
</li>
<li>
<label id="texto">Login:</label>
<input required="required" type="text" name="LoginAcesso" id="username" placeholder="Matrícula" class="form-control" />
</li>
<li>
<label>Senha:</label>
<input required="required" type="password" name="SenhaAcesso" id="password" placeholder="Senha" class="form-control" />
<button type="button" id="show_password" name="show_password" class="fa fa-eye-slash" aria-hidden="true"></button>
</li>
<li class="text-right">
<button type="submit" name="submit" class="btn btn-primary">Acessar</button>
</li>
</ul>
</form>