SweetAlert: Unexpected 2nd argument

1

Good afternoon, I have the following code:

function desactivar(idcategoria)
{
swal({
 title: "Desactivar Categoría",
 text: "¿Está Seguro de desactivar la Categoría?",
 type: "warning",
 showCancelButton: true,
 confirmButtonColor: "#DD6B55",
 confirmButtonText: "Si,desactivar!",
 closeOnConfirm: false
},
function(result){
if (result) {
$.post("../ajax/categoria.php?op=desactivar",{idcategoria : idcategoria},function(e){
swal("Desactivado!",e, "success");
tabla.ajax.reload();
});
}

});

}

But when you press the button that executes the function, this appears:

  

Uncaught SweetAlert: Unexpected 2nd argument

I do not know exactly how to solve it, could you please help me?

Thank you!

    
asked by Betto Rodriguez 05.10.2017 в 19:45
source

1 answer

0

The code you describe in your answer is from a version before 2, you should currently use promises , check the guide .

swal("Click on either the button or outside the modal.")
.then((value) => {
  swal('The returned value is: ${value}');
});

In fact another detail is that closeOnConfirm is no longer used, you must use closeModal .

swal({
 title: "Desactivar Categoría",
 text: "¿Está Seguro de desactivar la Categoría?",
 type: "warning",
 showCancelButton: true,
 confirmButtonColor: "#DD6B55",
 confirmButtonText: "Si,desactivar!",
 closeModal: false

   }).then(
  ...
  ...
});
    
answered by 05.10.2017 / 20:47
source