An AJAX error status always returns 0, inserts correctly in my BD but does not show success message, shows error message when status === 0, I execute 3 AJAX functions in a click event of a button, both functions that are invoked are executed correctly, the AJAX function is the one that sends the message that is inside the condition status === 0
$("#btnGuardafactura").click(function (event) {
var cantidadSim = $("#txtValorTotalSim").val();
var cantidadArticulo = $("#txtValorTotalArticulo").val();
//alert("guardar");
var varFactura = $("#txtfactura").val();
var varNombre = $("#txtNombre").val();
var varApellidop = $("#txtApellidoA").val();
var varApellidom = $("#txtApellidoM").val();
var varFechaCompra = $("#txtfechaCompra").val();
var varEmailu = $("#txtEmail").val();
var varArchivo = $("#rutaPdf").val();
if (cantidadSim == cantidadArticulo) {
fn_Ajax_Articulo();
fn_Ajax_sim();
var cargando = $("#muestraSeccion").html("<center><img src='../Images/cargando1.gif' height='50px' width='50px'/><br/>Un momento por favor...<center>");
$.ajax({
type: 'POST',
url: 'guardarFactura',
data: {
"factura": varFactura,
"nombre": varNombre,
"apellidop": varApellidop,
"apellidom": varApellidom,
"fechaCompra": varFechaCompra,
"emailUsuario": varEmailu,
"archivo":varArchivo
},
success: function (resultado) {
cargando.hide();
alert(resultado);
},
error: function (jqXHR, textStatus, errorThrown) {
if (jqXHR.status === 0) {
alert('Not connect: Verify Network.=(');
} else if (jqXHR.status == 404) {
alert('Requested page not found [404].');
} else if (jqXHR.status == 500) {
alert('Error Interno del Servidor [500].');
} else if (textStatus === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (textStatus === 'timeout') {
alert('Time out error.');
} else if (textStatus === 'abort') {
alert('Ajax request aborted.');
} else {
alert('Uncaught Error: ' + jqXHR.responseText);
}
}
});
} else {
alert("La cantidad de articulos debe ser la misma que la cantidad de SIM")
event.preventDefault();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
error that appears printing the variables of .error (...) with console.log