首页 > 解决方案 > jQuery confirm alerts arent shown

问题描述

Im using jquery-confirm libray from this site: https://craftpip.github.io/jquery-confirm/

im trying to customize all my warnings and insertion confirms but the execution is entering in ajax call and jquery-confirm function so the alert is showing for miliseconds because the execution continues and dont stop at the alert. Here is some code, this is ajax code:

$.ajax({
        type:"POST",
        url : '/proyecto/Api',
        data :  { action: 'addConcesionario', auth_token: auth_token, usuario_sesion: usuario, nomConcesionario: nomConcesionario.value, nifConcesionario: nifConcesionario.value, nomCiudad: nomCiudad.value, nomAdministrador: nomAdministrador.value, cpConcesionario: cpConcesionario.value, telefono: telefono.value, direccion:direccion.value},
        success : function(response) {
            mensajePopup( 1,"/proyecto/administracion/administracion.jsp","Insertion successful","", "green")
            window.location.href = "/proyecto/administracion/administracion.jsp";

        }, error: function(result) {
            alert("ERROR");
        } 

    });

Here is jQuery-confirm alert code:

function mensajePopup( tipoPopup,ruta,titulo,mensaje, color ){


    valor = false;
    if(color==""){color="green";}

    if(ruta==""){ruta="/proyecto/administracion/administracion.jsp";}
    switch (tipoPopup){
        case 1: //Aviso generico
            $.confirm({
                 title: titulo,
                 content: mensaje,
                 type: color,
                 buttons: {
                     Aceptar: function(){
                        window.location.href = ruta;     
                     }
                 }
             });

I have tried removing window.location.href but it reload the form and gets stuck there without showing anything.

thanks in advance!

标签: javascriptjquery

解决方案


推荐阅读