Storage of POST variables in JQuery / Javascript

0

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.

    
asked by AntonioMP87 12.04.2017 в 11:19
source

3 answers

0

You could store the variables in the browser's cookie, which is what you usually do when you are developing without a database (PHP).

I recommend this library: link

How are you going to send the variables to the server without PHP? I do not think that you need to save the variable POST, you keep them and then you tell them in the communication how the communication will be.

Greetings.

    
answered by 12.04.2017 / 11:30
source
1

What you want to do is consume an API that is very different from not using PHP. With javascript you can make requests of type AJAX as you expose it in your example and if you can send any data you need As an example to send data in a POST request you can occupy something like this

$.ajax({
  method: "POST",
  url: "some.php",
  data: { name: "John", location: "Boston" }
})
  .done(function( msg ) {
    alert( "Data Saved: " + msg );
  });
    
answered by 12.04.2017 в 14:24
0

Javascript is client language, you can not query the database with it. You have to use the server language you have. In this case, you talk about PHP.

For the next try to give more details, as parts of your code. ;)

    
answered by 12.04.2017 в 11:27