I have the following concern.
I have a form that is sent through ajax and validated before its submission with formvalidation. Everything works fine, but I need the notification to be shown in the file where it will be redirected after the ajax success.
The first notification window is generated through SWAL and there asks if you want to send or not the order and after that, generates the notification with toastr.
This is my code:
<script>
$(document).ready(function() {
var newDate = new Date(Date.now() + <?php echo $dia_max?>*24*60*60*1000);
$('#datePicker').datepicker({
format: 'dd/mm/yyyy',
autoclose: 'true',
language: 'es',
daysOfWeekDisabled: [0, 6],
startDate : newDate
})
.on('changeDate', function(e) {
$('#envia_pedidoE').formValidation('revalidateField', 'date');
});
});
$('#envia_pedidoE').formValidation({
framework: 'bootstrap',
excluded: ':disabled',
fields: {
obs: {
validators: {
notEmpty: {
message: 'Ingrese Obs. de Pedido.'
}
}
},
date: {
validators: {
notEmpty: {
message: 'Seleccione Fecha'
},
date: {
format: 'DD/MM/YYYY',
message: 'Formato Fecha NO VALIDO'
}
}
}
}
}).on('success.form.fv', function(e) {
$(document).ready(function(){
$('#envia_pedidoE').submit(function(e){
e.preventDefault();
var datos = $(this).serialize();
$.ajax({
type:"POST",
url: "envioE.php",
data : datos,
success:function(data){
var href = "archivoderedireccion.php";
swal({
title: "Realizará Envío de Pedido",
text: "Para Usuario",
icon: "info",
buttons: true,
dangerMode: true,
})
.then((envio) => {
if (envio) {
$.toast({
heading: 'Envío de Pedido',
text: 'Proceso Realizado con Exito. El Pedido Fué Enviado Correctamente.',
position: 'top-right',
loaderBg: '#ff6849',
icon: 'success',
hideAfter: 4500,
stack: 6
});
window.location.href = href;
} else {
$.toast({
heading: 'Envío de Pedido',
text: 'Se Ha Cancelado en Envío del Pedido.',
position: 'top-right',
loaderBg: '#ff6849',
icon: 'error',
hideAfter: 4500
});
}
});
$('#respuesta').html(data);
}
});
});
});
});
As I was saying, the above works but the message disappears immediately and what I need is to do a redirection to file addressirection.php and in that file the toastr notification is displayed.
If anyone has any idea how to do it or guide me in any way, I would greatly appreciate it. As always grateful in advance, for your help.
Greetings to all.