I have a form of login
, which has to send some data by post and store it in a array
with which we will work to make varied queries with databases (all this without using PHP). To all this, I wanted to know if javascript / JQuery can store POST variables.
In index.html
I have this script. It is responsible for collecting the form values and sending it to the JS functions page.
<script>
$(document).ready(function(ev){
$url="funciones.js";
/* SECCION INICIO SESION */
$('.container').on('click','#btnIniSesion', function(ev){
ev.preventDefault();
var datos={
"mail":$('#Mail').val(),
"clave":$('#Clave').val(),
"accion":"IniSesion"
}
$.ajax({
type:"post", //Tipo de peticion
url:$url, //URL pagina a cargar
data:datos, //Datos a pasar a pagina PHP
success: function(data){
$('#container').html(data);
}
});
});
/* FIN SECCION INI_SESION */
});
And here is the html form that is inside the same file:
<form role="form">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="E-mail" name="email" type="email" id='Mail' autofocus>
</div>
<div class="form-group">
<input class="form-control" placeholder="Password" name="password" type="password" id='Clave'value="">
</div>
<div class="checkbox">
<label>
<input name="remember" type="checkbox">Recuerdame
</label>
</div>
<button class="btn btn-lg btn-success btn-block" id="btnIniSesion">Login</button>
</fieldset>
</form>
I have not written anything else, since I can not get to create the javascript functions without knowing if it is possible to receive the form data without using PHP.