form Submit with button jQuery

0

I have a two-page form and I want to use the jQuery button event on page 1 on page 2, to display a jQuery message:

Page 1 index

<form method="post" action="Guardar.html">
     <input type="submit" name="boton" id="boton"/>
</form>

Page 2 Save.html

<link href="https://cdn.jsdelivr.net/sweetalert2/6.0.1/sweetalert2.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/sweetalert2/6.0.1/sweetalert2.min.js"></script>   
<script>
$("#boton").submit()("click",function(){
    swal({
    title: 'Alerta con cierre automatico!',
    text: 'Esta alerta se cerrara en 2 segundos.',
    timer: 2000
}).then(
    function () { },// handling the promise rejection
    function (dismiss) {
        if (dismiss === 'timer') {
        console.log('La alerta fue cerrada en 2 segundos')
        location.href = 'index.html';
    }
    }
    )
})
</script>

I want to call the button on my form to that page with jQuery to make it work

    
asked by Tony Muñoz 08.11.2016 в 17:10
source

1 answer

0

Friend, what you want to do is not the most tidy, but if you want to make that work for you, change your code on page 2 for this:

 $(document).ready(Alerta);

 function Alerta() {
   swal({
     title: 'Alerta con cierre automatico!',
     text: 'Esta alerta se cerrara en 2 segundos.',
     timer: 2000
   }).then(
     function() {}, // handling the promise rejection
     function(dismiss) {
       if (dismiss === 'timer') {
         console.log('La alerta fue cerrada en 2 segundos')
         location.href = 'index.html';
       }
     }
   )
 }
    
answered by 08.11.2016 / 18:28
source