I have tried everything and I can not catch the errors like for example when there is no internet connection or when you can not make the request with the server, I hope you understand me and can help me, I have said that you can handle the errors in the success, but I still do not know how to do it, I leave you the code.
$.ajax({
data: parameters,
url: 'createClient.php',
type: 'post',
// It runs during the sending of the request
beforeSend:function(response){
$('#cargando').css({display:'block'});
$('#exito').html('Procesando...');
},
//Se ejecuta cuando termino la petición
complete:function(response){
$('#exito').html('Exito...');
},
// se ejecuta al termino de la petición y está fue correcta
success: function (response) {
console.log(response);
//Cargamos finalmente el contenido deseado
location.href ="reparacion-iphone-cdmx-gracias.php";
},
error: function (response) {
alert(error con la petición);
}
});