Good someone could tell me why it does not enter my condition if it is only a validation to check if the vin of the car exists if it is not only shows message and if it is if it inserts me it is in MVC, it marks me error in the code only in the controller it marks that the car was found correctly and since at the same time it enters the else of the if of incomplete parameters, I was printing everything but I did not find anything.
mi js
$('.prueba_manejo_tabla').click(function(){
var id = $('#contacto_prueba_manejo').val();
var persona = $('#persona_prueba_manejo').val();
var fecha = $('#fecha_prueba_manejo').val();
var ciudad = $('#ciudad').val();
var inv = $('#idinventario').val();
if(inv !='' && fecha !='' && persona !=''){
$.ajax({
url: base_url + "buscar/buscar_auto",
type: "POST",
dataType: "json",
data : {contacto : id, inv : inv, persona : persona, fecha : fecha},
success: function(json, textStatus, jqXHR){
console.log(json);
console.log(textStatus);
console.log(jqXHR);
console.log(inv);
if (json.success) {
swal('Bien', 'SE ENCONTRO VIN', 'success');
$.getJSON(base_url+'contacto/registrar_prueba_manejo_inventario', {contacto : id, inv : inv, persona : persona, fecha : fecha}, function(data)
{
swal({
title: json.titulo,
text: json.mensaje,
type: json.status,
showCancelButton: false,
confirmButtonText: 'ok',
}).then(function(){
$('#modal_prueba_manejo').modal('hide');
$('#contacto_prueba_manejo').val('');
$('#idcontacto').val('');
$('#idinventario').val('');
$('#persona_prueba_manejo').val('');
if (ciudad == 'Tijuana')
var newWindow = window.open("");
});
});
}else{
swal('Error!', 'NO SE ENCONTRO VIN', 'error');
}
},
complete: function(textStatus, jqXHR){
},
error: function(textStatus, errorThrown, jqXHR){
console.log(textStatus);
console.log(errorThrown);
console.log(jqXHR);
}
});
}else{
swal('Error!', 'Favor de llenar todos los campos', 'error');
}
});
CONTROLLER
$respuesta = array ();
if(isset($_POST['inv']))
{
$prueba_manejo = $this->Contactomodel->buscar_auto();
print_r($prueba_manejo);
if($prueba_manejo)
{
$respuesta['status'] = true;
$respuesta['titulo'] = 'Listo!';
$respuesta['mensaje'] = 'Auto encontrado';
}
else
{
$respuesta['status'] = false;
$respuesta['titulo'] = 'Error!';
$respuesta['mensaje'] = 'Error al registrar prueba';
}
}
else
{
$respuesta['status'] = 'error';
$respuesta['titulo'] = 'Error!';
$respuesta['mensaje'] = 'Parametros incompletos prueba';
}
echo json_encode($respuesta);